SubViewController按钮单击操作不起作用

时间:2017-11-26 13:50:34

标签: ios objective-c uiviewcontroller uibutton

我有AViewController和BViewController。当我在AViewController中添加BViewController作为subView并且BViewController有一个按钮时。在这个时候BViewController按钮不起作用。

AViewController.m

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
BViewController bViewController =  [sb instantiateViewControllerWithIdentifier:@"BViewController"];
[self.view addSubview:bViewController.view];
[self.view bringSubviewToFront:bViewController.view];

BViewController.m

#import "BViewController"

@interface BViewController ()

@end

@implementation BViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}
- (IBAction)buttonAction:(id)sender {
    // here buttonAction not working
    [self.view removeFromSuperview];
}
@end

这里ButtonAction不起作用。谢谢你的帮助。

0 个答案:

没有答案