我有我的iPhone導航應用程序中的自定義UIButton類。當用戶點擊按鈕時,我呈現一個模式視圖,顯示用戶可以從中選擇的記錄的表格視圖列表。iPhone的自定義UIButton不能DismissModalViewController
在按鈕的點擊創建我的viewController和使用下面的代碼顯示它:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
dropDownPickerViewController = [[DropDownListingViewController alloc] initWithNibName:@"DropDownListingView" bundle:[NSBundle mainBundle]];
.....
.....
[[(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate] navigationController] presentModalViewController:dropDownPickerViewController animated:NO];
[dropDownPickerViewController release];
[super touchesEnded:touches withEvent:event];
}
正如你可以看到按鈕可以在任何的viewController,所以我從應用程序的委託搶navigationController。在我的DropDownPickerViewController代碼中,當用戶選擇一條記錄時,我有以下幾點:
[[(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate] navigationController] dismissModalViewControllerAnimated:NO];
但是什麼也沒有發生。它似乎凍結和掛起,不允許任何與表單的交互。任何想法爲什麼我的ModalViewController不會被解僱?我認爲這是我使用應用程序委託呈現viewController的方式。有沒有辦法在UIButton類中去self.ParentViewController,這樣我就可以獲得按鈕所在視圖的ViewController(如果這是問題)?
任何想法將不勝感激。
感謝
感謝您的回覆。但已經嘗試過,並沒有區別 – Matt