我創建了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];
}
調用UIActionSheet delegate
方法:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Delete"])
{
//do your stuff in here
}
}