我有一個帶有三個欄按鈕的地圖,可顯示地圖中顯示的不同標記。如果我點擊一個酒吧按鈕,特定的標記會顯示在地圖上,這已經很棒了。iPhone:使用視圖作爲關閉按鈕的透明覆蓋圖
現在我想用一個按鈕再次關閉覆蓋並顯示標記(在背景中設置)後單擊帶有標記描述的透明覆蓋圖(彈出窗口) 。
杆按鈕的功能:
- (IBAction)routeTwo:(id)sender
{
// The code for the overlay
// ...
// remove any annotations that exist
[map removeAnnotations:map.annotations];
// Add any annotations which belongs to route 2
[map addAnnotation:[self.mapAnnotations objectAtIndex:2]];
[map addAnnotation:[self.mapAnnotations objectAtIndex:3]];
[map addAnnotation:[self.mapAnnotations objectAtIndex:4]];
[map addAnnotation:[self.mapAnnotations objectAtIndex:5]];
}
我嘗試以下可能性:
1.使用模態的視圖控制器
RouteDescriptionViewController *routeDescriptionView = [[RouteDescriptionViewController alloc] init];
[self presentModalViewController:routeDescriptionView animated:YES];
[routeDescriptionView release];
工程偉大,但問題是:背景中的地圖視圖不再可見(配置模態視圖的alpha值不會改變任何內容)。
2.添加RouteDescriptionView作爲一個子視圖
RouteDescriptionViewController *routeDescriptionView = [[RouteDescriptionViewController alloc] init];
[self.view addSubview:routeDescriptionView.view];
[routeDescriptionView release];
也相當實用,但這裏的問題是:我不能在子視圖配置一個關閉按鈕來關閉/刪除子視圖(RouteDescriptionView )。
3.使用UIAlertView中
會按預期工作,但UIAlert是不是真的可定製的,因此不適合我的需要。
任何想法如何實現這一目標?
我認爲選擇2是您最佳的選擇。爲什麼你不能在子視圖上放一個按鈕?這應該不成問題。 – progrmr 2010-05-27 23:20:55
我沒有考慮在子視圖上添加按鈕。正如你可以在下面看到的,它工作!也非常感謝您指出正確的方向。 – axooh 2010-05-28 11:50:48