2
我在我的視圖中有一個UITableView。我的UITableView的名稱是tblTask。
我正在使用touchesBegan方法來獲取我的視圖的x和y座標。
獲取X和Y座標視圖
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self.view];
NSLog(@"point........ %f .. %f",location.x,location.y);
}
但是當我從tbltask開始觸摸事件時。即使tbltask是主視圖的子視圖,它也不會返回location.x和location.y。
我試圖禁用表的滾動視圖也沒有發生。
當我設置這個。
tbltask.userInteractionEnabled=NO;
然後,它會給出座標,但即使啓用了tbltask交互,我也希望視圖的座標。
也許最簡單的方法是將繼承'UITableView'並重寫'的touchesBegan:','touchesMoved:'和'touchesEnded:'方法。不要忘記打電話給他們的[超級...]等價物。 – 2012-04-18 10:23:24
好的會嘗試。然後讓你知道。 – KDeogharkar 2012-04-18 10:29:17
你能否澄清一下你想要的東西 - 你的視角的x,y,還是你的觸摸的x,y?你的代碼將返回你的觸摸的x,y。 – SomaMan 2012-04-18 10:57:22