【发布时间】:2014-03-10 21:54:21
【问题描述】:
我正在重构我采用的ViewController,并在控制器代码中创建UIViews。我想将其移至自定义 UIView,但想在控制器中处理手势识别器。
我有一个ItemViewController,它有一个自定义的UIView。在ItemController 中,我想做这样的事情:
ItemView *itemView = [[ItemView alloc] initWithFrame:CGRectMake(30.0f,_runningYPosition,100.0f, 50.0f)];
UITapGestureRecognizer *tapRecognizer2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognized:)];
itemView.miHeaderLabel.tag = [item itemID];
[itemView.miHeaderLabel addGestureRecognizer: tapRecognizer2];
引用
- (void)tapRecognized:(id)sender
{
...
}
在ItemViewController 中(不在自定义视图中)。
但它似乎不起作用。是否可以将 GestureRecognizer 添加到作为 ViewController 中子视图属性的标签中?有什么明显的我做错了吗?
【问题讨论】:
标签: ios uiview uilabel uigesturerecognizer