【问题标题】:iOS UIView push view controlleriOS UIView 推送视图控制器
【发布时间】:2012-09-30 00:27:19
【问题描述】:

当用户选择 UIView 时是否可以推送视图控制器?我有一个 UIView,其中显示地址和坐标,当用户触摸它时,我希望它推送到我的地图视图控制器,它将在其中绘制注释等等......谢谢!

【问题讨论】:

  • 使用 UITapGestureRecognizer 抓取触摸,然后从手势识别器委托方法中推送 VC。

标签: ios uiview mkmapview pushviewcontroller user-interaction


【解决方案1】:

您的地址和坐标应位于视图内(如标签)。如果你在上面设置了tap guesture,然后点击,你可以推送视图控制器。

例如,如果它是一个标签,这里有一个相关的 SO 帖子显示处理标签上的点击:iOS using UITapGestureRecognizer with UILabel to swipe to the next page

在该示例中,它们正在滚动到下一页,在您的代码中,您将推送视图控制器。

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleAddressTap:)]; 
[view.addressLabel addGestureRecognizer:tap];  // bind the tap to your label with your address ...

- (void) handleAddressTap: (UIGestureRecognizer *) gesture {
    // push your view controller here
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多