gpt4 book ai didi

iphone - 尝试设置手势识别时崩溃

转载 作者:可可西里 更新时间:2023-11-01 06:25:17 25 4
gpt4 key购买 nike

我试图在我的代码中设置一个点击手势,但在我尝试确定坐标时遇到了崩溃。任何帮助将不胜感激。

2012-09-14 17:25:49.149 valhalla[16469:707] tap detected
2012-09-14 17:25:49.159 valhalla[16469:707] -[UITapGestureRecognizer translationInView:]: unrecognized selector sent to instance 0x37bf10
2012-09-14 17:25:49.165 valhalla[16469:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITapGestureRecognizer translationInView:]: unrecognized selector sent to instance 0x37bf10'
*** First throw call stack:
(0x3104c88f 0x3611d259 0x3104fa9b 0x3104e915 0x3104f788 0x7a4a1 0x31870637 0x31800d65 0x31a31479 0x3177cf55 0x3177baa3 0x317887e9 0x31788627 0x317881f5 0x3176e695 0x3176df3b 0x313e222b 0x31020523 0x310204c5 0x3101f313 0x30fa24a5 0x30fa236d 0x313e1439 0x3179ccd5 0x75307 0x752c8)




#import "GLViewController.h"
#import "GLView.h"

@implementation GLViewController

- (void)loadView {

CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];

GLView *glView = [[[GLView alloc] initWithFrame:applicationFrame] autorelease];
self.view = glView;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSingleTap:)];
singleTap.numberOfTapsRequired = 1;
[self.view addGestureRecognizer:singleTap];
[singleTap release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// We can run in landscape mode
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}

/*- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

//[self.view becomeFirstResponder];
//[self.view setReturnKeyType:UIReturnKeyDone];
}*/
- (void)didReceiveMemoryWarning
{
// default behavior is to release the view if it doesn't have a superview.

// remember to clean up anything outside of this view's scope, such as
// data cached in the class instance and other global data.
[super didReceiveMemoryWarning];
}

- (void) handleSingleTap: (UIPanGestureRecognizer *) uigr
{
NSLog(@"tap detected");
CGPoint translation = [uigr translationInView:self.view];
CGPoint finalPosition = self.view.center;
finalPosition.x += translation.x;
finalPosition.y += translation.y;

}

@end

最佳答案

您声明了 UITapGestureRecognizer,但您的方法正在转换为 UIPanGestureRecognizer

- (void) handleSingleTap: (UIPanGestureRecognizer *) uigr

UITapGestureRecognizer 没有声明 translationInView。这就是您的应用崩溃的原因。

关于iphone - 尝试设置手势识别时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12432853/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com