2012-08-13 100 views
0

我似乎無法推動這個視圖控制器,我必須做一些錯誤的。代碼視圖控制器不會推

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
// Do any additional setup after loading the view from its nib. 
button = [UIButton buttonWithType:UIButtonTypeCustom]; 
[button addTarget:self action:@selector(pushToStart) forControlEvents:UIControlEventTouchUpInside]; 
} 

- (void)pushToStart 
{ 
ViewController *view = [[ViewController alloc]init]; 

[[self navigationController] pushViewController:view animated:YES]; 

} 

我在做什麼錯?

+0

你有一個navigationController?如果加上'的NSLog(@ 「%@」,self.navigationController);''在什麼pushToStart'你在控制檯中看到什麼? – deanWombourne 2012-08-13 19:00:10

+0

'initWithNibName:束:' – Desdenova 2012-08-13 19:05:22

+0

@deanWombourne(空)。我該如何設置一個? – 2012-08-13 19:06:52

回答

1

創建一個UINavigationController編程,或使用Interface Builder做到這一點 - 有教程在線上如何做到這一點100的。例如here