2012-09-30 68 views
1

當用戶選擇UIView時,是否可以推視圖控制器?我有一個顯示地址和座標的UIView,當用戶觸摸它時,我希望它推送到我的地圖視圖控制器,它將繪製註釋,等等......謝謝!iOS UIView推視圖控制器

+1

使用UITapGestureRecognizer抓取觸摸,然後從手勢識別器委託方法中只需按下VC即可。 – endy

回答

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 
} 
+0

美麗。謝謝。 –