1
這是我的筆尖文件和地圖視圖的屏幕,但地圖總是採取整個view.I嘗試重置我的模擬器和清理我的Xcode,但沒有任何作品。我在做有問題? 我是否需要以編程方式爲mapview提供框架?mkmapview根據nib文件中的幀不顯示
我還希望按鈕是對MapView類的頂部如果地圖不能設置取特定幀。
考慮下面的代碼,請:
#import "mapViewController.h"
@interface mapViewController()
@end
@implementation mapViewController
@synthesize mapView,source,dest,latdest,latsource,longdest,longsource;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
[email protected]"delhi";
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0,0,160,240)];
CLGeocoder *geocoder1 = [[CLGeocoder alloc] init];
[geocoder1 geocodeAddressString:source
completionHandler:^(NSArray* placemarks, NSError* error)
{
for (CLPlacemark* aPlacemark in placemarks)
{
coordinate.latitude = aPlacemark.location.coordinate.latitude;
latsource=&coordinate.latitude;
coordinate.longitude = aPlacemark.location.coordinate.longitude;
longsource=&coordinate.longitude;
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
[annotation setCoordinate:(coordinate)];
[annotation setTitle:source];
annotation.subtitle = @"I'm here!!!";
mapView.delegate = self;
[self.mapView addAnnotation:annotation];
}
}];
}
你試過以編程方式設置框架嗎? – NightFury
還沒有,但我試過嗎? –
顯然。有時它發生,我們不能從nib文件管理代碼,然後我們嘗試以編程方式執行它 – NightFury