user08092013 user08092013 - 10 months ago 68
Objective-C Question

navigate from one page to another in x code

How can i navigate from one page to another page in x code? remember without using the interface builder.... i want the answer programatically?

Answer Source

Although your question is not much clear but still I would like to give a try...

You can use

UIViewController *yourViewController = [[YourViewControllerClass alloc] initWithNibName:@"<name of xib>" bundle:nil];
[self presentModalViewController:yourViewController animated:YES];
[yourViewController release];

In case the new view is also to be created programmatically, you can do that in the viewDidLoad method of YourViewControllerClass and change the initialization to

UIViewController *yourViewController = [[YourViewControllerClass alloc] init];

In YourViewController when you wish to come back to previous view on some button action you can use

[self dismissModalViewControllerAnimated:YES];

Another way that you can do is

UIViewController *yourViewController = [[YourViewControllerClass alloc] init];
[self addSubview:[yourViewController view]];

and to remove the view you can use

[self.view removeFromSuperview];

Hope this works for you, if yes please communicate....:)