我遇到一些麻煩,無論是UIAlertView
或UIActionSheet
偷重點不放手後鎖定。查看UIActionSheet或UIAlertView中(iPhone/iPad的)
詳細說明,我有一個用戶按下按鈕的設置。然後顯示帶有UITextField的UIAlertView
。當用戶按下「確定」按鈕時,會顯示一個UIActionSheet
(從UIAlertView
委託方法調用),以確認與用戶有關的事情。但是,當他們按下其中一個按鈕時,UIActionSheet
會消失,但焦點不會返回到主視圖。
我一直在玩,無論我似乎做什麼我總是以我的主要UIView
被這樣的圖層覆蓋(顯然你可以看起來像我通過圖層)。我試圖刪除視圖的所有子視圖,但它沒有任何成功。
請有人可以幫我嗎?
這裏是源代碼:
// This method displays the UIAlertView which contains a UITextView linked up to a
// UIPickerView.
- (IBAction)buttonPressed:(id)sender
{
UIAlertView *deleteAlert = [[UIAlertView alloc] initWithTitle:@"Delete Something"
message:@"Select something to delete:"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
deleteAlert.alertViewStyle = UIAlertViewStylePlainTextInput;
deleteAlert.tag = kDeleteAlert;
deleteTextField = [deleteAlert textFieldAtIndex:0];
[pickerView reloadAllComponents];
deleteTextField.inputView = pickerView;
[deleteAlert show];
}
// The UIAlertView delegate method is then used to display a UIActionSheet to confirm
// whether the user wants to proceed.
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
UIActionSheet *confirmDelete = [[UIActionSheet alloc] initWithTitle:@"Delete blah?"
delegate:self
cancelButtonTitle:@"No"
destructiveButtonTitle:@"Yes"
otherButtonTitles:nil];
confirmDelete.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[confirmDelete showInView:self.parentViewController.tabBarController.view];
}
// Then the focus should be returned to the original view (i.e. where the first button
// was pressed to launch the UIAlertView. However the focus is still locked and the
// view appears slightly dimmed around the edges.
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == actionSheet.destructiveButtonIndex)
{
// Do some stuff ...
}
}
非常感謝你的幫助!我真的很感激它 - 我是如此堅持這個問題。 – 2012-01-14 13:01:02
我更新了我的答案,很高興幫助 - 歡呼聲。 – Skybird 2012-01-14 13:14:45