2

I am having trouble in showing infobutton to navigate to information page/view.

I have written this code.

UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
toolBar.items = [NSArray arrayWithObjects:infoButtonItem, nil];

I got infolight button but i do not now know how to do animate & navigation action method in to flip to info page.

I also want infobutton to stay at center, currently it is at left corner.

Artemix
  • 2,113
  • 2
  • 23
  • 34

2 Answers2

1
This will create ur info button in center.
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
    UIBarButtonItem *infoButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
    [infoButton addTarget:self action:@selector(goToRechercherView) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *flexibleLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    toolbar.items = [NSArray arrayWithObjects:flexibleLeft,infoButtonItem,flexibleLeft, nil];


This is for swipe animation. add your view inside.
-(void)goToRechercherView{
    [UIView beginAnimations:@"flipview" context:nil];
    [UIView setAnimationDuration:2];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                           forView:self.view cache:YES];
    [UIView commitAnimations];
}
Ankit Bhardwaj
  • 221
  • 2
  • 9
  • Thanks, it`s working. I have added flipviewcontroller.h .m .xib to project,so when i click on info button i want to go to that page. do you know how to do that? –  Dec 24 '12 at 09:50
0

There are two ways to do this...

First one is......

newView setFrame:CGRectMake( 0.0f, 480.0f, 320.0f, 480.0f)]; //notice this is OFF screen!
[UIView beginAnimations:@"animateView" context:nil];
[UIView setAnimationDuration:0.4];
[newView setFrame:CGRectMake( 0.0f, 0.0f, 320.0f, 480.0f)]; //notice this is ON screen!
[UIView commitAnimations];

Second option is to use built in animations as flip and curl:

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                               forView:newView
                                cache:YES];

    [self.navigationController.view addSubview:settingsView.view];
    [UIView commitAnimations];
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76