0
我前幾天遇到了這個問題,我也搜索瞭解決方案無處不在,但沒有工作好。我添加一個按鈕到自定義viewController(是UIViewController的子類),然後,將customView添加到myMainViewController中。 這樣的代碼:UIButton在UIViewController的子類中沒有響應任何觸摸
customView.h
cusomView:UIViewController
{
UIButton *myButton;
}
-(void)doSomething:(id)sender;
customView.m
-(void)viewDidLoad
{
[super viewDidLoad];
self.view=[UIView alloc] initWithFrame:CGRectMake(0,100,100,100);
//init the button....
[myButton addTarget:self action:@selector(doSomething:) forControlEvents:...upInside];
[self.view addSubViews:myButton];
}
-(void)doSomething:(id)sender
{
.......
}
myMainViewController
-(void)viewDidLoad
{
......
customView *cusView=[customView alloc] init];
[self.view addSubViews:cusView];
}
只是如此,這顯示效果出色,但按鈕不repond你幫我感謝任何touches.Could?