我遇到一些麻烦,无论是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