我知道當錯誤是''等於'未在此範圍內聲明時「意味着對象未被正確創建,但是當我創建通知中心用於iOS的widget,使用WeeLoader模板和THEOS進行編譯,我得到這個錯誤:'UITapGestureRecognizer'沒有在這個範圍內聲明。(WeeLoader)'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中工作。
謝謝。
謝謝你的迴應,我曾試圖在init創建'UITapGestureRecognizer',viewDidLoad中,並且還試圖在界面中創建它。仍然是同樣的錯誤:(也是方法名稱是一個錯字寫在這個問題,對不起。 – 2013-03-04 01:14:19
@RandomAwesomeGuy你可以發佈更多的代碼嗎? 這對我有用http://pastebin.com/VuH4Gk8G – badger0053 2013-03-04 01:30:27
這裏是我的代碼http://pastebin.com/fG9EdTsT – 2013-03-04 02:23:59