我知道這可能是很簡單的問題,但我不能這樣做,我使用@selector駁回視圖,編寫這些代碼,沒有發生:@selector沒有發生
- (void)viewDidLoad {
//here create my button
dismiss = [UIButton buttonWithType:UIButtonTypeRoundedRect];
dismiss.frame = CGRectMake(100, 10, 60, 50);
[dismiss setTitle:@"Close" forState:UIControlStateNormal];
[dismiss setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[dismiss addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:dismiss];
}
//here the function
- (void)closeView {
[self dismissViewControllerAnimated:YES completion:nil];
}
但沒有發生,我在哪裏做錯了?
感謝
您closeview方法exicuting與否? – sanjeet 2014-10-29 11:11:26
它發生的原因可能是因爲你的視圖控制器不是一個模態視圖,因此沒有什麼可以解散的 - 你是否試圖調用'[self.navigationController popViewControllerAnimated:TRUE];'方法呢? – holex 2014-10-29 11:14:25
是的,當我點擊解僱按鈕,打電話給我的虛空,但沒有發生 – BlackSheep 2014-10-29 11:14:57