Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios (WeeLoader)和#x27;UITapGestureRecognitor';未在此范围中声明_Ios_Objective C_Uitapgesturerecognizer_Theos - Fatal编程技术网

Ios (WeeLoader)和#x27;UITapGestureRecognitor';未在此范围中声明

Ios (WeeLoader)和#x27;UITapGestureRecognitor';未在此范围中声明,ios,objective-c,uitapgesturerecognizer,theos,Ios,Objective C,Uitapgesturerecognizer,Theos,我知道,当错误为“'blah'未在此范围内声明”时,意味着对象未正确创建,但当我使用WeeLoader模板和THEOS为iOS制作通知中心小部件进行编译时,我收到了此错误:“UITapgestureRecognitizer”未在此范围内声明 这是我的.mm文件: - (void)loadFullView { UITapGestureRecognizer *Tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@

我知道,当错误为“'blah'未在此范围内声明”时,意味着对象未正确创建,但当我使用WeeLoader模板和THEOS为iOS制作通知中心小部件进行编译时,我收到了此错误:“UITapgestureRecognitizer”未在此范围内声明

这是我的.mm文件:

- (void)loadFullView {
     UITapGestureRecognizer *Tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];


     UIImage *bg = [[UIImage imageWithContentsOfFile:@"/System/Library/WeeAppPlugins/WeeAppTest.bundle/WeeAppBackground.png"] stretchableImageWithLeftCapWidth:5 topCapHeight:71];
     UIImageView *bgView = [[UIImageView alloc] initWithImage:bg];
     bgView.frame = CGRectMake(0, 0, 316, 71);     
     bgView.userInteractionEnabled = YES;

     [bgView addGestureRecognizer:Tap];

     [_view addSubview:bgView];
     [bgView release];
     [Tap release];

      UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 316, 71)];
      lbl.backgroundColor = [UIColor clearColor];
      lbl.textColor = [UIColor whiteColor];
      lbl.text = @"Hello world";
      lbl.textAlignment = UITextAlignmentCenter;
      [_view addSubview:lbl];
      [lbl release];
}

-(void) handleTapGesture:(UIGestureRecognizer *) sender {

}
我做错了什么?我非常确定我正确地声明了所有内容,顺便说一句,代码确实与UITapGestureRecognitor一起工作


谢谢。

我想这里发生了一些事情

我认为您可能会出现范围外错误,因为手势识别器应该在
viewDidLoad
init
方法中声明

另外,在
UITapGestureRecognizer*中,点击=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleSingleTap:)]调用方法
handleSingleTap:


因此,您的方法应该是
-(void)handleSingleTap:(UITapGestureRecognizer*)sender

谢谢您的回复,我已尝试在init、viewdidload中创建
UITapGestureRecognizer
,也尝试在界面中创建它。还是同样的错误:(.方法名称也是写问题时的输入错误,对此很抱歉。@RandomAwesomeGuy你能发布更多的代码吗?这对我很有用。@RandomAwesomeGuy我相信问题在于你的类是
NSObject
类型的,你应该在
UIViewController
类中创建手势识别器非常感谢,我会的我试过了,我从没想过:P