2013-05-09 69 views
0

我試圖通過動態創建地圖視圖來獲取地圖視圖,但地圖視圖只顯示淺黃色視圖。我導入了MKMapView和CoreLocation框架。這是我的代碼,請幫我解決這個問題。提前致謝!!MapView未顯示 - 目標C

MKMapView *map_view; 
    map_view = [[MKMapView alloc] initWithFrame:frame]; 
    map_view.showsUserLocation = YES; 
    map_view.mapType = MKMapTypeHybrid; 
map_view.delegate = self; 
    [_scrollView addSubview:map_view]; 
+0

您的問題解決了還是不行? – 2013-05-10 06:17:07

+0

@SAMIRRATHOD yup ..這是設置框架的一些問題,它現在已經修復。 :) – 2013-05-10 09:26:43

回答

0

在.h文件中可以插入以下

@interface YourViewController : UIViewController <MKMapViewDelegate> 
{ 

    IBOutlet MKMapView *mapview; 
} 

@property(nonatomic, retain) IBOutlet MKMapView *mapview; 

在.m文件可以插入以下

@implementation YourViewController 

@synthesize mapview; 

-(void)ViewDidLoad 
{ 
    mapview.mapType=MKMapTypeStandard; 
    mapview.showsUserLocation = YES; 
    mapview.delegate=self; 
} 
+0

我通過改變視圖的框架來做到這一點。謝謝.. :) – 2013-05-10 12:30:32

+0

歡迎這個代碼也工作正常 – Maul 2013-05-11 05:48:44