bitwise37 Posted November 3, 2008 Share Posted November 3, 2008 I created a View-Based Application in XCode. On the main view there is a UIButton. Then I created a second view called View2.xib which has the UILabel that says "Second View". Now, all I want to do is display the second view when you click on the button. In the view controller class for the first view that contains the button I added. #import View2ViewController.h … View2ViewController *View2; … And I added the property for this. This class also has the IBAction for the button click event, which works just fine and executes when clicked. Now, in the .m file I obviously @synthesize View2; and begin to edit the button click method to display the view. Here is the code: <BR>if(self.View2 == nil) {<BR> View2ViewController *two = [[View2ViewController alloc] initWithNibName:@"View2″ bundle:[NSBundle mainBundle]];<BR> self.View2 = two;<BR> [two release];</P> <P>}<BR> [self.navigationController pushViewController:self.View2 animated:YES];<BR> Everything complies, and runs. When I click on the button the application does NOT display the second view. Nothing crashes, but it doesn't display the view. What am I doing wrong. I have everything linked up in Interface Builder. It's quite basic. Is a "View-Based Application" not the correct type for doing this? Thanks everyone. Link to comment https://www.insanelymac.com/forum/topic/134651-basic-application-not-switching-between-views/ Share on other sites More sharing options...
velkropie Posted November 11, 2008 Share Posted November 11, 2008 I created a View-Based Application in XCode. On the main view there is a UIButton. Then I created a second view called View2.xib which has the UILabel that says "Second View". Now, all I want to do is display the second view when you click on the button. In the view controller class for the first view that contains the button I added. #import View2ViewController.h … View2ViewController *View2; … And I added the property for this. This class also has the IBAction for the button click event, which works just fine and executes when clicked. Now, in the .m file I obviously @synthesize View2; and begin to edit the button click method to display the view. Here is the code: <BR>if(self.View2 == nil) {<BR> View2ViewController *two = [[View2ViewController alloc] initWithNibName:@"View2″ bundle:[NSBundle mainBundle]];<BR> self.View2 = two;<BR> [two release];</P> <P>}<BR> [self.navigationController pushViewController:self.View2 animated:YES];<BR> Everything complies, and runs. When I click on the button the application does NOT display the second view. Nothing crashes, but it doesn't display the view. What am I doing wrong. I have everything linked up in Interface Builder. It's quite basic. Is a "View-Based Application" not the correct type for doing this? Thanks everyone. i tried to do the same using the view based app, and couldn't get it to work. i just gave up and went with the Tab Bar App instead. i know it sucks...sorry man, good luck!!! Link to comment https://www.insanelymac.com/forum/topic/134651-basic-application-not-switching-between-views/#findComment-961756 Share on other sites More sharing options...
Recommended Posts