因爲我有一個以上的元件以在MapView一個給定的位置處顯示,我想當給定MKPinAnnotationView已經選擇在的MKMapView以顯示WEPopoverController。的iOS:WEPopoverController中的MKMapView
呈現的內容,這是一個實現代碼如下工作正常爲止。我已經分類了MKPinAnnotationView,當註釋視圖被點擊時,我打電話給我的自定義呈現方法。
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
[view openCustomPopoverInFrame:self.view.frame];
[mapView deselectAnnotation:view.annotation animated:NO];
if (_lastAnnotationView != view) {
[_lastAnnotationView closeCustomPopover];
_lastAnnotationView = view;
}
}
- (void) openCustomPopoverInFrame:(CGRect) frame {
CGRect fromFrame = self.frame; //Pin Annotation View Frame
WEPopoverContentViewController *contentViewController = [[WEPopoverContentViewController alloc] initWithStyle:UITableViewStylePlain];
contentViewController.delegate = self;
WEPopoverController *viewController = [[WEPopoverController alloc] initWithContentViewController:contentViewController];
//[viewController setPassthroughViews:[NSArray arrayWithObjects:contentViewController.view, contentViewController.tableView, nil]];
viewController.delegate = self;
//set the displayed content
....
_myPopoverController = [viewController retain];
[viewController presentPopoverFromRect:fromFrame inView:self.superview permittedArrowDirections:UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown animated:YES];
[contentViewController release];
[viewController release];
}
在的tableview細胞也選擇按鈕的工作查找和我得到預期的響應(該方法被調用和popovercontroller停留在視圖層次結構的頂部)。
我的問題是,當我點擊WEPopoverController內容(其中一個表格視圖單元格,在沒有按鈕的中心位置)時,點擊事件會傳遞給地圖視圖,因此隱藏了彈出窗口控制器。我能做什麼,以防止通過點擊事件?
我嘗試了幾種解決方案例如設置passThroughViews並且在WETouchableView中操作hitTest:withEvent:方法並始終返回nil,但這對我沒有幫助。
最佳 尼克
編輯
我現在已經調試的則hitTest:withEvent:方法方法在WETouchableView多一點的部門,似乎,它總是返回UITableViewCellContentView的一個實例,我認爲這應該是正確的。
編輯
所以要多一點點清晰,我想顯示酥料餅的控制器,當它被挖掘它應該neighter消失就像是一般的註釋行爲,也沒有潛在的觀點應該被調用。它應該保持在視圖的頂部,tap事件應該被表視圖捕獲並調用特定的方法(tableView:didSelectRowAtIndexpath :)。
我已經看過this解決方案,但它似乎不適合我和底層視圖(這是地圖視圖)被調用。