【问题标题】:Error [NSISLinearExpression orientationChanged:]: unrecognized selector sent to instance错误 [NSISLinearExpressionorientationChanged:]:无法识别的选择器发送到实例
【发布时间】:2014-02-28 04:40:04
【问题描述】:

当我改变方向时,我在应用程序中遇到了这个错误,这是我人生中第一次遇到这种错误,我以前从未见过这种类型的错误,

我已经搜索了很多关于这个错误的信息,但我没有找到解决这个问题的方法,

在我的应用程序中,我已经为方向更改编写了 NSNotification

Scroller.m

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

        scrollView=[UIScrollView new];
        pageControl=[UIPageControl new];
        scrollView.delegate=self;

        scrollView.pagingEnabled=YES;
       scrollView.showsHorizontalScrollIndicator=NO;
        scrollView.showsVerticalScrollIndicator=NO;

        scrollView.translatesAutoresizingMaskIntoConstraints=NO;
        pageControl.translatesAutoresizingMaskIntoConstraints=NO;


        scrollView.backgroundColor=[UIColor clearColor];
        pageControl.backgroundColor=[UIColor darkGrayColor];
        [pageControl addTarget:self action:@selector(changePage) forControlEvents:UIControlEventValueChanged];

        [self addSubview:scrollView];
        [self addSubview:pageControl];
        self.pageControl.currentPage = 0;
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
        [self setData];

    }
    return self;
}

-(void)orientationChanged{
 [self updateFrame];

}
-(void)updateFrame{

    [self layoutIfNeeded];
    CGRect mainFrame=scrollView.frame;
    CGRect frame;
.
.
.
.
    // COdes for Updating Frame
}

但我收到此错误:

-[NSISLinearExpression orientationChanged:]: unrecognized selector sent to instance 0xa9477c0 2014-02-28 09:56:04.919 TKScroller[604:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSISLinearExpression orientationChanged:]: unrecognized selector sent to instance 0xa9477c0'

编辑:

我在观察者和方法中删除了参数,并且 运行后出现新错误

[__NSArrayM orientationChanged]: unrecognized selector sent to instance 0xa0845f0 2014-02-28 10:27:40.202 Scroller[810:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM orientationChanged]: unrecognized selector sent to instance 0xa0845f0'

已解决

我在 dealloc 方法中删除了观察者

- (void)dealloc {

    [[NSNotificationCenter defaultCenter] removeObserver:self];

}

【问题讨论】:

  • 你谷歌了吗???您向 NSISLinearExpression 对象发送了orientationChanged: 消息,并且该类没有该名称的方法!
  • @HotLicks:是的,我在谷歌搜索过[NSISLinearExpression orientationChanged:],但我没有找到任何东西,这就是我在这里提出问题的原因。
  • 我已编辑问题,请检查。
  • 您没有搜索“无法识别的选择器”。
  • 如果不清楚,NSArray 也没有实现orientationChanged:。向我们展示堆栈跟踪!

标签: ios iphone objective-c ios7 uiinterfaceorientation


【解决方案1】:

经过这么多尝试,我发现我没有删除观察者,所以我在dealloc方法中删除了它。

- (void)dealloc {

    [[NSNotificationCenter defaultCenter] removeObserver:self];

}

【讨论】:

    猜你喜欢
    • 2012-04-04
    • 1970-01-01
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-24
    相关资源
    最近更新 更多