我有一个UIViewController (ViewController A)在屏幕上,我想添加一个小的UIViewcontroller (ViewController B)作为父ViewController (ViewController A)的标题。
在ViewController A上,我有:
- (void)viewDidLoad {
[super viewDidLoad];
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestView" bundle:[NSBundle mainBundle]];
[self.view addSubview:self.test.view];
}在ViewController B上,我有一个测试按钮:
- (IBAction)buttonTest:(id)sender
{
}此buttonTest从不被调用。你有什么办法让它工作吗?
谢谢
发布于 2012-07-23 16:55:00
- (void)viewDidLoad {
[super viewDidLoad];
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestView" bundle:[NSBundle mainBundle]];
[self.view addSubview:self.test.view];
}将变量*test声明为类级别,以使其保留在生命周期中。
https://stackoverflow.com/questions/10386281
复制相似问题