Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

adamlah

macrumors newbie
Original poster
Jul 15, 2008
2
0
I have a PageAViewController.m containing the following code..

Code:
-(id)init {
 if (self = [super init]) {
  self.title = @"Page A";
  UIBarButtonItem *navButton = [[UIBarButtonItem alloc] initWithTitle:@"Page B" style:UIBarButtonItemStylePlain target:self action:@selector(doPush)];
  self.navigationItem = navButton;
 }
 return self;
}

-(void)loadView {
 PageAView *pageAView = [[PageAView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
 [self setView:pageAView];
}

-(void)doPush {
 PageBViewController *pageBViewController = [[[PageBViewController alloc] init] autorelease];
 [self.navigationController pushViewController:pageBViewController animated:YES];
}

This sets up a PageAView controlled by PageAViewController with a navigation button to initialize PageBViewController (that controls PageBView) and slide it over.

Within PageAView I have a UIButton I also want to trigger the slide. I can't work out how to do this. I would imagine it to be something like...

Code:
UIButton *button ........
[button addTarget:self action:@selector([self.viewController doSlide]) forControlEvents:UIControlEventTouchUpInside];

..to call the function in PageAViewController. However I can't work this out.

Thanks :)
 

white89gt

macrumors regular
Jan 18, 2006
133
0
Instead of trying to call the doSlide method in the PageAViewController from the PageAView, the easier thing to do would be to access the navigation controller from the application delegate and push the new view controller that way.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.