开发者

UIViewController not responding to presentModalViewController for modal navigation

I am trying to implement a modal navigation controller as described in the Apple iOs Guide: Combined View Controller Interfaces

I have come to the conclusion that I am missing something both obvious and stupid as I simply cannot get anything to display, I get a blank white screen.

Swapping things out I can prove that the view controller that I am using as the navigation controllers RootViewController works fine on it's own (by adding it manually as a view subChild).

Further, implementing addSubView ([self.view addSubview:navController.view]) instead of presentModalViewController seems to work OK.

Can anyone point out my simple error because I am 5 minutes short of kicking my own face :D

header

#import <UIKit/UIKit.h>

@interface BaseViewController : UIViewController {

}

implementation

#import "BaseViewController.h"
#import "ScannedListViewController.h"
#import "ScannedItemViewController.h"

@implementation BaseViewController

- (void)viewDidLoad {

    ScannedListViewController *listViewController = [[ScannedListViewController alloc] init];
    ScannedItemViewController *itemViewController = [[ScannedItemViewController alloc] init];

    UINavigationController *navController = [[UINavigationController alloc] initWithRootView开发者_高级运维Controller:listViewController];
    [navController pushViewController:itemViewController animated:NO];

    [self presentModalViewController:navController animated:YES];

    [listViewController release];
    [itemViewController release];
    [navController release];

    [super viewDidLoad];

}

The RootControllerView is a basic test TableViewController with the following header

@interface ScannedListViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource>

Thank you in advance if your able to help


Why are you presenting something modally in a view controller's viewDidLoad method? I find that odd off the top. Generally you show a modal view controller in response to some action (like tapping a button).

Is there a reason you're showing a navigation controller with a second view controller already pushed on it after the root?

You should have [super viewDidLoad] as the first line, not the last line, of the method.

You do not need to have <UITableViewDelegate, UITableViewDataSource> after UITableViewController because it already adopts those protocols. Remove that bit.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜