长按时UILongPressGestureRecognizer不显示ActionSheet

时间:2012-10-08 19:34:50

标签: iphone ios6

长按2秒钟时,应显示带保存照片按钮的操作表 但是行动表没有显示出来。

 UILongPressGestureRecognizer *gestureRecognizer = [[UILongPressGestureRecognizer alloc]
                                               initWithTarget:self
                                               action:@selector(handleLongPress:)];
    gestureRecognizer.minimumPressDuration = 2.0;
     imageScrollView.userInteractionEnabled = YES;
     [imageScrollView addGestureRecognizer:gestureRecognizer];
    gestureRecognizer.delegate = self;
    [gestureRecognizer release];

- (void)handleLongPress:(UILongPressGestureRecognizer*)gestureRecognizer{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan){
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Save Photo", nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
    [actionSheet showInView:self.view];
    [actionSheet release];

}

}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
    case 0:
        //UIImageWriteToSavedPhotosAlbum(imageView, self, @selector(image: didFinishSavingWithError:contextInfo:), nil);

        break;

    default:
        break;
}
}

我在代码中做错了什么。

感谢您的帮助。

0 个答案:

没有答案