您的SampleViewController不在Window层次结构中,您需要在窗口中进行设置。
在你的appDelegate中,这样做,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[SampleViewController alloc] initWithNibName:@"SampleViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
如果你正在使用故事板,在didFinishLaunchingWithOptions方法中这样使用,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
                                                             bundle: nil];
Â
    SampleViewController *mainViewController = (SampleViewController*)[mainStoryboard
                                                       instantiateViewControllerWithIdentifier: @"SampleViewController"];
Â
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
Â
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window setRootViewController:navigationController];
    [self.window setBackgroundColor:[UIColor whiteColor]];
    [self.window makeKeyAndVisible];
Â
    return YES;
}
在您的视图控制器中,
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *action_9 = [defaults objectForKey:@"url"];
if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"url"] isEqualToString:@"aa9"])
{
inboxData *screen=[[inboxData alloc]initWithNibName:@"inboxData" bundle:nil];
screen.strGetTableSelect=@"1";
[self presentModalViewController:screen animated:YES];
}
}