开发者

iPhone problem with loading view with button

开发者 https://www.devze.com 2023-03-24 12:21 出处:网络
In one of my classes I have a button that when pressed loads another view controller and view. This is what I use:

In one of my classes I have a button that when pressed loads another view controller and view. This is what I use:

FormController *formController1=[[FormController alloc]initWithNibName:nil bundle:nil];
[self presentModalViewController:formController1 a开发者_高级运维nimated:YES];

The problem is that it loads the full view, but not the navigation bar that comes with all the other views. What am I doing wrong?


Maybe you shouldn't be using a modal view controller. If you want the view to appear as part of the navigation stack, you need to load push the view controller onto the navigation view's stack.

If you want the new modal view controller to be a navigation view controller, then make formController the root view controller of a UINavigationController, and present the navigation controller as the modal view controller.


Read the UIViewController Class Reference first:

On iPhone and iPod touch devices, the view of modalViewController is always presented full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.

presentModalViewController:animated: sets the modalViewController property to the specified view controller, resizes its view and attaches it to the view hierarchy.

Do you have nib file for your FormController? If so, you can set the prompt to Navigation Bar there.

If you wanted to display your view over another view you can use awakeFromNib (which actually gives you the view), which must be implemented in your ConfirmController class. You do not use initWithFrame, but as I can see by your class name ConfirmController, is this class just to show a confirmation message or does it do something fancy? If so, then you could have used a simple UIView/UIAlertView.

0

精彩评论

暂无评论...
验证码 换一张
取 消