viewController の scrollView に小さな mapView (65x65) を実装しました。XIB ごとに mapView の位置を設定し、シミュレータまたは iOS デバイスで実行すると、正しい位置に配置されません。
- XIB 右位置
- iPhone 5~ハイ
- iPhone 4 (またはシミュレーター) はかなり高い
これらのコードを使用して状況ごとに位置を修正できますが、これでは解決できません。
XIP の同じ位置のコード:
CGRect newFrameMapView = CGRectMake(10,171,65,65);
mapView.frame = newFrameMapView;
iPhone 5 での出力用に修正するコード:
CGRect newFrameMapView = CGRectMake(10,215,65,65);
mapView.frame = newFrameMapView;
iPhone 4 での出力用に修正するコード:
CGRect newFrameMapView = CGRectMake(10,302,65,65);
mapView.frame = newFrameMapView;
ノート:
- 一番上にナビゲーションコントローラーがあります。
- mapView を scrollView の外に出しても何も変わりません。
- 自動レイアウトを使用しない
--- 編集 --- 2013.01.23 -----------------------------------
コードの他の部分の位置を変更しないように、「mapView」の名前を「mapView2」に変更しました。
.h の重要なコード フラグメントを次に示します。
#import <MapKit/MapKit.h>
@interface ViewControllerDetail : UIViewController <MKMapViewDelegate> {
IBOutlet MKMapView *mapView2;
}
@property(nonatomic, retain) IBOutlet MKMapView *mapView2;
@end
そして.m
@implementation ViewControllerDetail
@synthesize mapView2;
[...]
// Basic Settings Map
[mapView2 setMapType:MKMapTypeStandard];
[mapView2 setZoomEnabled:NO];
[mapView2 setScrollEnabled:NO];
[mapView2 setDelegate:self];
// Map Start
MKCoordinateRegion myStartRegion = { {0.0, 0.0}, {0.0, 0.0} };
myStartRegion.center.latitude = 44.087439;
myStartRegion.center.longitude = 2.139614;
myStartRegion.span.latitudeDelta = 0.003;
myStartRegion.span.longitudeDelta = 0.003;
[mapView2 setRegion:myStartRegion animated:NO];
// Map Point
MKCoordinateRegion myBeispielRegion = { {0.0, 0.0}, {0.0, 0.0} };
myRegion1.center.latitude = 44.087439;
myRegion1.center.longitude = 2.139614;
classAnnotation *annotationRegion1 = [[classAnnotation alloc] init];
annotationRegion1.coordinate = myRegion1.center;
[mapView2 addAnnotation:annotationRegion1];