tags:

views:

38

answers:

3

Hi Guys,

I've created a new view based application and added button on it and I want to open another view on button click. I've added another view and trying opening from there but nothing happening. Please help me explaining step by step process of adding and opening second view from first view as I am pretty new in Iphone App development. I must be missing something may be UINavigationViewController etc. I am using the code below to open the second view.

  • (IBAction)ShowList:(id) sender

{
if(self.atmList == nil)

{

ATMList *viewController = [[ATMList alloc] initWithNibName:@"ATM List" bundle:nil];

self.atmList = viewController;

[viewController release];

}
[self.navigationController pushViewController:atmList animated:YES];
}

Your quick reply will be highly appreciated. Thanks in advance.

A: 

oh kidha pagi. you dont need a navigation controller to switch views. I didnt anyway. I had a very simple application and needed to switch from view 1 to view 2. simple as that. assuming you are in the same situation you can follow the following tutorials. I like to learn visually so i have given you two video tutorials which should help you tremendously.

Solution 1: Follow this tutorial: start from scratch so you can get your head around switching views from view 1 to view 2 as you are new to this, then implement it in your own code once you understand what is going on. http://www.youtube.com/watch?v=HaAPa3gIwMY

Solution 2: However when i was programming for the iphone and i was stuck in switching views i followed this tutorial: http://www.youtube.com/watch?v=XnvCEQfbiv8&feature=channel

Hope this helps you.

Let me know if it does

PK

Pavan
gud examples...thanks
Amarpreet
A: 

A navigation controller isn't required - though if you do create one it gives you a back button when you do push a new view. Handy, but for the most simple use, I suggest you replace the line

[self.navigationController pushViewController:atmList animated:YES];

with

[self.view addSubView:atmList];

Note that my syntax might be a little off :P

Also, when you do this, make sure that the IBAction is connected to the button you made using the "Touch Up Inside" action.

Apart from that, I would second Pavan's suggestion of playing around with some tutorials. They don't necessarily have to be video tutes, though they help a lot with the Interface Builder.

Good luck!

Andrew Natoli