ストーリーボードを使用してタブ バー アプリを作成しています。
基本的に SecondViewController で、ビューなどを変更するためのツールバーを上部に持つ MKMapView をセットアップします。
そのスパンを設定し、画面が読み込まれたときに表示される注釈を追加しました。以下に示すように、AutoLayout:Off を使用すると正しく表示されます
(申し訳ありませんが、ここに新しいリンクを埋め込むことができませんでした)
http://img211.imageshack.us/img211/9359/mvautooff1.jpg
AutoLayoutをOnにすると、これが行われます
http://img153.imageshack.us/img153/3736/mvautoon.jpg
スパンなどを変更してみましたが、シミュレーターを実行しても何も変わりません。
AutoLayout がオフのときのように MapView が表示されるように変更するにはどうすればよいですか?
デバイスなどのサイズを変更するときに AutoLayout をオンにしたいのですが、AutoLayout がオフのときの様子を示すには MapView が必要です。
私はiOSコーディングに非常に慣れておらず、完全に初心者です
どんな助けでも大歓迎です!
ありがとう
.m のコードは -
#import "SecondViewController.h"
#import "Annotation.h"
@interface SecondViewController ()
@end
//Coordinates of Salon
#define SALON_LATITUDE -33.427528;
#define SALON_LONGITUDE 151.341697;
//Span
#define THE_SPAN 0.005f;
@implementation SecondViewController
@synthesize myMapView;
//Find my location button
-(IBAction)findmylocation:(id)sender {
myMapView.showsUserLocation = YES;
myMapView.delegate = self;
[myMapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
}
//Set map type button
-(IBAction)setmaptype:(id)sender {
switch (((UISegmentedControl *)sender).selectedSegmentIndex) {
case 0:
myMapView.mapType = MKMapTypeStandard;
break;
case 1:
myMapView.mapType = MKMapTypeHybrid;
break;
case 2:
myMapView.mapType = MKMapTypeSatellite;
break;
default:
myMapView.mapType = MKMapTypeStandard;
break;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
//Create the region
MKCoordinateRegion myRegion;
//Center
CLLocationCoordinate2D center;
center.latitude = SALON_LATITUDE;
center.longitude = SALON_LONGITUDE;
//Span
MKCoordinateSpan span;
span.latitudeDelta = THE_SPAN;
span.longitudeDelta = THE_SPAN;
myRegion.center = center;
myRegion.span = span;
//Set our mapView
[myMapView setRegion:myRegion animated:YES];
//Annotation
//1. Create a coordinate for use with the annotation
CLLocationCoordinate2D salonLocation;
salonLocation.latitude = SALON_LATITUDE;
salonLocation.longitude = SALON_LONGITUDE;
Annotation * myAnnotation = [Annotation alloc];
myAnnotation.coordinate = salonLocation;
myAnnotation.title = @"Generic Haircuts";
myAnnotation.subtitle = @"8888 Mann St, Gosford, 2250";
[self.myMapView addAnnotation:myAnnotation];
//Automatic annotation - CUSTOM CODE
[self.myMapView selectAnnotation:myAnnotation animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end