您的 SampleViewController 不在窗口层次结构中,您需要在窗口中设置。
在你的 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];
}
}