在MKMapView的子类中设置属性时出现异常

时间:2013-10-21 11:31:26

标签: iphone ios properties mkmapview subclass

我遇到了一个奇怪的错误。在发布模式下安装测试应用程序后,出现错误:

[SomeMapView setRotateEnabled:]: unrecognized selector sent to instance 0x1c58ac40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SomeMapView setRotateEnabled:]: unrecognized selector sent to instance 0x1c58ac40'

Mapview已初始化,在init方法中我尝试停用旋转。在调试模式下,它工作正常。

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self setRotateEnabled:FALSE];

        [self initDelegate];
    }
    return self;
}

也许有人知道发生了什么事?提前谢谢。

1 个答案:

答案 0 :(得分:0)

这是iOS版本中的一个问题。 RotateEnabled仅在iOS7中可用,如Suresh指出的那样。我必须检查属性是否存在(或检查是否有iOS7),如

if ([self respondsToSelector:NSSelectorFromString(elementName)]) 
{
    [self setValue:elementInnerText forKey:elementName];
}