2011-05-30 26 views
-2

標籤我的UIViewController與UITableView的,我給在3 example.now的UIViewController中標記的看法,我想認識在TouchBegin方法這個標籤編號:的UITableView在TouchBegin

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event 
{ 
    UITouch *touch = [[touches allObjects] objectAtIndex:0]; 
    CGPoint finger = [touch locationInView:self]; 
    int x = finger.x; 
    int y = finger.y; 

    int z = self.tag; 
} 

和問題是z總是0,我如何修改它的工作?

+0

你能發表更多的代碼嗎?上下文不清楚。 – csano 2011-05-30 23:52:59

+0

這是代碼,在viewDidLoad我把:self.view.tag = 3; 。然後我寫touchBegan方法,並希望得到這個標籤號碼,我總是得到0當我觸摸UITableView – yosifz8 2011-05-30 23:56:42

+0

這個代碼在哪裏?你想做什麼? – 2011-05-31 00:02:21

回答

0

你告訴我們你把self.view.tag = 3,這意味着它是你的UIViewController中的UIView,它被賦予了3的標籤。然後在touchesBegan中,你要求UIViewController中的標籤,它沒有意義。嘗試int z = self.view.tag。