Aravindhan Aravindhan - 3 years ago 54
Objective-C Question

navigate from one page to another in xcode

How can I navigate from one page to another page in xcode? remember without using the interface builder... I want the answer programmatically?

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....:)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download