我更像是一个 java 人,我刚刚开始使用 Objective C 和 iPhone 编程。
我一直在尝试此代码(Xcode iPhone 编程)以使 iPhone 在地图类型(分段控制按钮)之间切换,但它不断抛出“属性类型'mymap'与访问器类型'setMymap'不匹配”:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface ViewController : UIViewController {
MKMapView * mymap;
}
@property (nonatomic, readonly) MKMapView * mymap;
-(IBAction)setMymap:(id)sender;
-(IBAction)getLocation;
@end
@implementation ViewController
@synthesize mymap;
-(IBAction)getLocation {
mymap.showsUserLocation = YES;
}
-(IBAction)setMymap:(id)sender {
switch (((UISegmentedControl*)sender).selectedSegmentIndex) {
case 0:
mymap.mapType = MKMapTypeStandard;
break;
case 1:
mymap.mapType = MKMapTypeSatellite;
break;
case 2:
mymap.mapType = MKMapTypeHybrid;
break;
}
}
....