所以我有一個自定義視圖,我在viewcontroller的for循環中創建了很多。雖然正在創建它們,我打電話給他們每個人的這個方法:TapGestureRecognizer不會調用選擇器
-(void)setUpStuff{
//Random setup code
[self setUserInteractionEnabled:YES];
tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tileSelected:)];
tapGesture.numberOfTapsRequired = 1;
tapGesture.numberOfTouchesRequired = 1;
[self addGestureRecognizer:tapGesture];
}
,這是它應該被調用的選擇:
-(void)tileSelected{
NSLog(@"Why am I not working?");
[self.delegate tileSelected:self];
}
這也許值得一提的是,這customView有嵌入其中的imageView和標籤。我已經嘗試在imageView中添加手勢識別器,並確保imageView被帶到最前面,但是,這也行不通。任何想法?
也許你的問題已經是與[這](http://stackoverflow.com/questions/31049033/uitapgesturerecognizer-not-working-on -ios9)? – Leonardo
沒有運氣,我正在編程設置它,就像他在爲他工作時所做的那樣D: – DemetriP