ios – 选择器’setRegion:animated:’没有已知的类方法

我在 xcode中尝试了一些东西,我将这个代码用于我的MapView.

No kNown class method for selector 'setRegion:animated:'

我用3 .h和.m文件制作了三个View Controller.

我的错是什么?

.M

#import "myPlacesAllTime.h"
#import <MapKit/MapKit.h>



@interface myPlacesAllTime ()

@end

@implementation myPlacesAllTime

- (id)initWithNibName:(Nsstring *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        MKCoordinateRegion startRegion = { {0.0,0.0},{0.0,0.0} };
        startRegion.center.latitude = 35.88905;
        startRegion.center .longitude = -17.605591;
        startRegion.span.latitudeDelta = 0.1;
        startRegion.span.longitudeDelta = 0.1;
        [myPlacesAllTime setRegion:startRegion animated: NO];
    }

.H

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface myPlacesAllTime : UIViewController <MKMapViewDelegate>{

    __weak IBOutlet MKMapView *myPlacesAllTime;

}

@end

解决方法

你为这个班级选择了同名的myPlacesAllTime
该类的实例变量.

解决此问题,请重命名该类,例如到MyPlacesController或类似的. 请注意,约定是让类名以大写字母开头.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...