【发布时间】:2014-08-04 00:53:41
【问题描述】:
我是 iOS 开发新手。
我有一个带有按钮的 ViewController ViewController。当用户按下该按钮时,我想将视图切换到RegisterViewController。
ViewController.m 包含以下代码:
#import "ViewController.h"
#import "RegisterViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize registerViewButton;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)registerViewButtonClick:(id)sender {
NSLog(@"registerViewButtonClick called");
RegisterViewController* controller = [[RegisterViewController alloc] init];
[self.navigationController pushViewController:controller animated:YES];
}
@end
根据调试输出,当我按下按钮时,实际上调用了方法 registerViewButtonClick。
但是RegisterViewController代表的视图没有出现。
应用代码here可用。
当按下按钮时,为了让 RegisterViewController 的视图可见,我需要进行哪些更改?
【问题讨论】:
-
你真的有导航控制器吗?换句话说:
self.navigationController不是nil?
标签: ios objective-c cocoa-touch