裏面我想檢測觸摸子視圖內touchesMoved檢測子視圖
在我的主視圖控制器我加入了一個名爲子視圖:SideBarForCategory,它從屏幕左邊的30% - 作爲一個側邊欄。
SideBarForCategory *sideBarForCategory = [[SideBarForCategory alloc] initWithNibName:@"SideBarForCategory" bundle:nil];
[sideBarData addSubview:sideBarForCategory.view];
內SideBarForCategory,我想測試觸摸
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event touchesForView:self.view] anyObject];
CGPoint location = [touch locationInView:touch.view];
NSLog(@"Map Touch %f",location.x);
}
上面的代碼(touchesMoved)完美地工作在主視圖(視圖 - 控制),但我的子視圖(SideBarForCategory)內不工作 - 爲什麼以及如何修復它?
是你的側欄視圖'userInteractionEnabled'? – lukya 2012-03-12 13:14:14
是的,所有視圖都是 – chewy 2012-03-12 13:20:33