【问题标题】:Exception while setting property in subclass of MKMapView在 MKMapView 的子类中设置属性时出现异常
【发布时间】:2013-10-29 21:03:25
【问题描述】:

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

[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;
}

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

【问题讨论】:

  • 您的设备运行的是哪个操作系统? rotateEnabled 仅在 iOS7 中可用。
  • 是的,这就是问题所在。我更换了测试设备,IOS6出现问题。谢谢。

标签: iphone ios properties mkmapview subclass


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-22
    • 2010-12-06
    • 2015-10-06
    • 1970-01-01
    • 2011-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多