这是一个菜鸟问题..我创建了UIActionSheet。现在如何让它按下时执行“删除”。Get UIActionSheet执行操作
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeMotionShake)
{
// Handle shake notification
UIActionSheet *shakeActionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Delete"
otherButtonTitles:nil];
[shakeActionSheet showInView:self];
}
if ([super respondsToSelector:@selector(motionEnded:withEvent:)])
[super motionEnded:motion withEvent:event];
}
谢谢!好的,我还希望操作表消失,如果用户决定触摸屏幕而不是取消按钮,则不执行任何操作。我如何实现这一点? – user1779598
你需要使用'UITapGestureRecognizer' http://stackoverflow.com/questions/2623417/iphone-sdk-dismissing-modal-viewcontrollers-on-ipad-by-clicking-outside-of-it –
这是一个新问题。你应该标记其中一个正确的答案。点击手势识别器也是一个很好的答案。 – danh