views:

14

answers:

1

hi, my project first used the Three20 frame work for handling navigation.But due to some problems i ha to remove the three20 part.So im redesigning my app. what im trying to do is show a detail view when user touches a button.I created a new mainwindow as there was none earlier.It does not have a navigation controller. i used


DetailViewController *detailViewController=[[DetailViewController alloc] init]; [self.navigationController pushviewController:detailviewController animated:YES]

in the buttos touch up event. but when i run the app nothings hapens on button touch.No warnings or errors are shown. Ive done this in other apps but it just doesnt work here.

+1  A: 

Since you are not using a UINavigationController, the navigationController property of the your UIViewController will remain nil. "Compile-wise" there's no problem, since the property exists, but the compiler does not know the property will remain nil, hence no warnings/errors are shown.

Sending a message to a nil object is allowed in Objective-C, hence the code doesn't crash and does nothing when being run.

If you want to get your code up & running, you'll need to put the root UIViewController in a UINavigationController. Once the UIViewController is shown in a UINavigationController, the property will be set to the UINavigationController automatically.

Edit: You could use something like this, instead of showing someController, "encapsulate" it in a UINavigationController and show that controller.

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:someController];
Yannick Compernol
ok i get it.Just got confused as compiler showd no problem
Mithun Madhav