在TouchBegin中带有标记的UITableView

时间:2011-05-30 23:44:13

标签: iphone objective-c

我有UITiewController和UITableView,我给UIViewController标签中的视图为3例如。我想在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,我怎么能修改它才能工作?

1 个答案:

答案 0 :(得分:0)

你告诉我们你把self.view.tag = 3,这意味着你的UIViewController中的UIView被分配了3的标签。然后在touchesBegan中,你要求UIViewController中的标签,这不是没有意义。尝试int z = self.view.tag。