-1
我在viewController的scrollView中实现了一个小型mapView(65x65)。如果我设置每个XIB的MapView的位置,并在模拟器或iOS设备上是不是坐在正确的位置上运行它:元素在XIB和模拟器/ iOS设备中的不同位置
- XIB正确的位置
- iPhone 5的高
- iPhone 4(或模拟器)多少高
我可以纠正这些代码每个局势的立场,但是这不能成为解决方案:
代码在本地执行的相同位置:
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;
注:
- 我在顶部有一个navigationController。
- 如果我把mapView移出scrollView,没有什么变化。
- 我不使用自动布局
---编辑--- 2013年1月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];
我添加了我的代码片段。我希望它能澄清我的问题。 –