0

I have my iPad ViewController.xib with a button called about us. How to link that button to another page called about us. I have created one XIB file called about.xib. And how do i link that page. Also can I link back to the main viewController. Do i need to create another m or h files?

I have done this code but it doesn't work.

- (IBAction) About {
    UIViewController * about = [[UIViewController alloc] initWithNibName:@"About" bundle:nil];
    [self.navigationController pushViewController:about animated:YES];
    [about release];
}
Amink
  • 35
  • 11

1 Answers1

0
UIViewController * about = [[UIViewController alloc] initWithNibName:@"About" bundle:nil];
[self presentModalViewController:about animated:YES];
[about release];
Andrea Mario Lufino
  • 7,921
  • 12
  • 47
  • 78
  • When i replace your code. I have this problem : int retVal = UIApplicationMain(argc, argv, nil, nil); Program received signal. Its already being release [about release]. Any solution? – Amink Dec 07 '11 at 17:37
  • Try to remove [about release] and see what happen – Andrea Mario Lufino Dec 07 '11 at 18:54
  • When I press about button, it is successfully linked to XIB but when I press return it quits. Where should I put the release memory thing? I always get this error int retVal = UIApplicationMain(argc, argv, nil, nil); Program received signal. – Amink Dec 07 '11 at 19:29
  • To dismiss the modal controller write [self dismissModalViewControllerAnimated:YES] it works. The release is in the right point, after you present the controller. – Andrea Mario Lufino Dec 07 '11 at 19:38
  • Can you tell me where should I put the [self dismissModalViewControllerAnimated:YES]. Is it on the 2nd viewController or the main ViewController. My program still quits during the 2nd viewController when I press return – Amink Dec 08 '11 at 10:21
  • Here is my return button - (IBAction)btnReturn { [self.view removeFromSuperview]; [self dismissModalViewControllerAnimated:YES]; } – Amink Dec 08 '11 at 10:22
  • One more thing, how to set my 2nd viewController to fix to landscape same as main viewController when I press next button. – Amink Dec 08 '11 at 10:36
  • In your return method remove [self.view removeFromSuperview] : this method is used when you add a subview using [self.view addSubview:myView] and it's different from [self presentModalViewController:about animated:YES]. Use only [self dismissModalViewController:YES]. Your 2nd question : in the controller which appears pressing next button use the method - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationLandscapeRight; //or other orientation. If return YES it supports all orientations } – Andrea Mario Lufino Dec 09 '11 at 09:38
  • Can you help me at this link [link](http://stackoverflow.com/questions/8455576/ios-how-to-reference-a-music-background-from-a-singleton-class/8455595#8455595) – Amink Dec 11 '11 at 06:12