我有RootViewController的的子視圖,並呼籲時,按鍵不能被它壓而不會出現錯誤:無法按下按鈕的子視圖
Thread 1: EXC_BAD_ACCESS
這裏是重要的代碼:
的AppDelegate:
MainViewController *MainVC = [[MainViewController alloc]init] ;
self.window.rootViewController = mainVC ;
而在MainViewController類:
OtherViewController *SomeView = [[OtherViewController alloc]init] ;
[self.view addSubview:SomeView.view] ;
OtherViewController xib
按原樣加載(執行viewDidLoad
的東西)。但是,當我嘗試按模擬器中的某個按鈕(在OtherViewController
上)時,出現上述錯誤。
而且按鈕的代碼:
IBOutlet UIImageView *Image; //in OtherViewController.h
//in OtherViewController.m
- (IBAction)Button:(id)sender {
Image.center = CGPointMake(Image.center.x + 1, Image.center.y) ;
}
有斷點整個OtherViewController.h和.M(到處做的按鈕)。沒有被觸發。程序中斷並在AppDelegate中給出錯誤:return UIApplicationMain(argc,argv,nil,NSStringFromClass([AppDelegate class]));
我是不是正確設置第二個視圖以使其功能完整?我該如何擺脫我的程序這個錯誤?
什麼按鈕上的目標? –
不,如果你創建了一個按鈕,那麼可以是附加一個'IBAction',或者有一個'[button addTarget:action:forControlEvents:]'調用將選擇器附加到按鈕上。 –
你能在該IBAction中發佈代碼嗎? –