Subscribe ( )

iPhone Programming Tutorials

 

Forum

You must be logged in to post Login Register

Search 

Application Won’t Switch Views??

User Post

10:18 am
November 3, 2008


bitwise

Noob

bitwise

posts 2

1

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:

if(self.View2 == nil) {
        View2ViewController *two = [[View2ViewController alloc] initWithNibName:@”View2″ bundle:[NSBundle mainBundle]];
        self.View2 = two;
        [two release];

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

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.

11:29 am
November 18, 2008


VertigoSol

Moderator

posts 26

2

probably better not to store the view locally just do

View2ViewController *two = [[View2ViewController alloc] initWithNibName:@”View2″ bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:two animated:YES];
[two release]

just relialized your probably releasing the view before it is being pushed on the stack


About the iCodeBlog forum

Currently Online:

6 Guests

Maximum Online: 25

Forums:

Groups: 2

Forums: 6

Topics: 215

Posts: 617

Members:

There are 434 members

There are 1 guests


Brandon has made 87 posts

Top Posters:

bobcubsfan - 52

crazyiez - 30

VertigoSol - 26

Uhu - 17

AdeC - 17

Administrator: Brandon | Moderators: VertigoSol


© - Version 3.1.4 (Build 357)