我添加了向上滑动手势到图像,但是当滑动时,应用程序出现BAD_EXEC
错误。
这就是我所拥有的:
.h 文件:
@interface MyViewController : UIViewController <UIGestureRecognizerDelegate>
{
UISwipeGestureRecognizer* swipeUpGesture;
IBOutlet UIImageView* myImage; //Connected from Interface Builder
IBOutlet UIScrollView* myScrollView;
}
@property (retain, nonatomic) UISwipeGestureRecognizer* swipeUpGesture;
@property (retain, nonatomic) IBOutlet UIImageView* myImage;
@property (retain, nonatomic) IBOutlet UIScrollView* myScrollView;
.m 文件:
- (void)viewDidLoad
{
//myImage is inside of myScrollView
swipeUpGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swiped)];
[swipeUpGesture setDirection:UISwipeGestureRecognizerDirectionUp];
[swipeUpGesture setDelegate:self];
[myImage addGestureRecognizer: swipeUpGesture];
}
- (void)swiped:(UISwipeGestureRecognizer*)sentGesture
{
NSLog (@"swiped");
}
所以基本上,在 内myView
,我有myScrollView
。在里面myScrollView
,我有myImage
。
当我运行上面的代码时,应用程序一直运行直到我向上滑动,然后它实际上识别出滑动,但没有到达NSLog
,崩溃并且我得到BAD_EXEC
.
提前致谢。