Reputation: 357
I created a UIImageView. And when click on it, a UIActionSheet
will pop up.
@IBOutlet weak var avatarImageView: UIImageView!
@IBAction func tapUIImageViewHandler(sender: UITapGestureRecognizer) {
var popMenu: UIActionSheet = UIActionSheet(title: "Upload user avatar", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles: "Choose from library", "Take photo")
popMenu.showInView(self.view)
}
func actionSheet(popMenu: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){
println("click at index \(buttonIndex)")
switch buttonIndex {
case 2:
takePhoto()
case 1:
chooseFromLib()
default:
break
}
}
But when I run it on simulator, after I click the button on the UIActionSheet, I get
Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!
Can anyone help me with that? Thanks!
Upvotes: 0
Views: 2897
Reputation: 1377
Please implement small delay while presenting actionsheet.
[self performSelector:@selector(presentActionsheet) withObject:nil afterDelay:0.2f];
Upvotes: 1
Reputation: 3545
In my opinion, it is a bug (you should file a bug report. I tested a simpler project (with only a button and an action opening the ActionSheet, no delegate) in the following cases:
By the way I remember you that since iOS8 ActionSheet is replaced by UIAlertController
with UIAlertControllerStyle
set to ActionSheet
. But it is also true that we must continue to use ActionSheet, especially because we all probably still target version < 8.
Upvotes: 0