私は初心者です。ViewController.m にボタンがあります。ボタンを押すと、SecondViewController に移動する必要がありますが、SecondViewController は表示されません。
また、ナビゲーション バーの SecondViewController には、ViewController に戻るための [戻る] ボタンがあります。何が足りないのか教えてもらえますか?
ViewController.m:
-(IBAction)buttonPressed:(id)sender
{
EnglishViewController *v = [[[EnglishViewController alloc]
initWithNibName:@"EnglishViewController"
bundle:nil]
autorelease];
[self.navigationController pushViewController:v animated:TRUE];
}
AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
解決策(@Georgeの回答に依存):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
UINavigationController *navCon =[[[UINavigationController alloc]
initWithRootViewController:self.viewController]
autorelease];
self.window.rootViewController =navCon;
[self.window makeKeyAndVisible];
return YES;
}