我知道当错误是“'blah' is not declared in this scope”意味着没有正确创建对象时,但是当我为 iOS 制作通知中心小部件时,使用 WeeLoader 模板和 THEOS 进行编译,我收到此错误:未在此范围内声明“UITapGestureRecognizer”。
这是我的 .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 {
}
我究竟做错了什么?我很确定我正确地声明了所有内容,顺便说一句,代码确实可以在没有 UITapGestureRecognizer 的情况下工作。
谢谢你。