我有一個imageview,我只想點擊imageview的一側。是否可以爲手勢設置框架?任何人都可以提供解決方案嗎?如何爲TapGesture識別器設置框架
0
A
回答
1
使用UIGestureRecognizerDelegate
,我認爲你可以得到關於如何比較的想法:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch locationInView:yourview].x < somePoint.x) {
return false;
} else {
return true;
}
}
1
你可以覆蓋在ImageView的頂視圖和水龍頭識別到這個新的觀點,這樣的事情會使圖像tapable
UIView tapView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, imageView.frame.size.width/2, imageView.frame.size.height)];
[imageView addSubView:tapView]
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[tapView addGestureRecognizer:singleFingerTap];
0
您可以簡單地把UIView的上框,按您的要求,您的ImageView頂部的左側,把輕敲姿勢上的UIView。
您可以通過storyboard/xib或以編程方式完成此操作。
以編程方式,例如 - 您只想點擊寬度爲50px的imageView區域。對於這一點:
UIView *vw = [[UIView alloc] initWithFrame:CGRectMake(imgView.frame.origin.x, imgView.frame.origin.y, 50, imgView.frame.size.height)];
// add gesture to view
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
tapGesture.numberOfTapsRequired = 2;
[vw addGestureRecognizer:tapGesture];
[imgView addSubview:vw];
現在處理您雙擊
-(void)handleTapGesture:(UITapGestureRecognizer *)gesture
{
// handle double tap
}
相關問題
- 1. TapGesture在openflowview上識別ony
- 2. 如何識別nodejs框架
- 3. Bootstrap框架如何識別瀏覽器和設備寬度?
- 4. 實體框架 - 配置識別密鑰
- 5. 在UIPanGesture識別過程中設置框架以查看
- 6. 如何爲cell.imageView.frame設置框架?
- 7. 如何爲TheOs設置框架路徑?
- 8. 如何在ImagePickerController()中的疊加視圖上識別TapGesture?
- 9. 如何在Swift中爲手勢識別器設置'enabled'屬性
- 10. Crashlytics框架無法識別
- 11. 形狀識別框架?
- 12. 識別.Net框架版本
- 13. 如何設置cell.imageview框架
- 14. 如何設置ContainerViewController框架?
- 15. 如何識別Microsoft Bot框架IForm中的哪個ActiveDelegate爲TRUE?
- 16. 設置爲播放框架
- 17. 將框架設置爲UIActionSheet
- 18. 如何將框架設置爲在MapAnnotation上設置的UIImage
- 19. 設置微鏈接識別器RegexParserSettings
- 20. 如何檢測/識別設備鎖定屏幕設置是否設置爲無?
- 21. 如何在Phalcon框架的Model :: query()中設置別名
- 22. 如何在實體框架中設置事務級別?
- 23. 如何設置語音識別服務器?
- 24. 如何設置語音識別器啓動和停止
- 25. 如何以編程方式設置SAPI識別器
- 26. 機器人框架:套件設置和測試設置之間的區別?
- 27. GIT如何設置.gitconfig將* .woff文件識別爲二進制
- 28. 如何將'requiresuniqueemail'設置爲false以識別身份?
- 29. UITableView tapgesture行爲
- 30. play.libs.WS在Play框架中無法識別
只需添加攝像畫面的透明視圖一面,再加入姿態這一觀點...... –
歡迎蘇米... –
歡迎來到堆棧溢出!我編輯了你的問題的標題,包括更多的細節,並澄清你的問題。您無法爲螞蟻類型的手勢設置框架,您將手勢識別器添加到視圖對象,然後可以操縱視圖的框架或在添加輕擊手勢的視圖中測試輕擊的位置。 –