2
我更喜歡java人,我剛開始使用Objective C和iPhone編程。我一直在嘗試這個代碼(Xcode iPhone編程),使iPhone在地圖類型(分段控制按鈕)之間切換,但它繼續拋出「類型的屬性'mymap'不匹配類型的訪問者'setMymap' 「:房地產類型與訪問者類型不匹配mkmapview
#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;
}
}
....
謝謝!它編譯得很好 –