2013-09-22 31 views
0

我现在有两个ViewControllers(2 .h.m,并.xib文件),并希望他们进行切换时按下按钮(即选项按钮。)
enter image description here enter image description here enter image description here你如何切换ViewControllers?

我想使屏幕切换到Options.xib文件,但不知道如何做到这一点。 (该.pngs只是推出图像。)我不是很在Objective-C经历(完整的代码,将不胜感激。)谢谢:)

回答

1
#import "OptionViewController.h" 


- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [optionsButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
} 

- (IBAction)buttonPressed:(id)sender 
{ 
    OptionViewController *vc = [[OptionViewController alloc] initWithNibName:nil bundle:nil]; 
    [self presentViewController:vc animated:YES completion:^(void){}]; 
} 
+0

这是什么文件? – blustone

+0

这需要进入实现文件(.m文件),无论哪个视图控制器在屏幕上,并包含您想要连接此操作的按钮。您还需要代码才能将操作附加到按钮上(我将编辑我的答案)。 – bneely

+0

它有助于该按钮被称为选项按钮 – blustone

0

Ctrl drag从按钮到Options View Controller并选择modal

相关问题