2014-02-28 57 views
2

我的应用程序得到这个错误,当我改变方向,我知道了人生第一次,我以前从未见过这种类型的错误,错误[NSISLinearExpression orientationChanged:]:无法识别的选择发送到实例

我有搜索很多关于这个错误,但我没有发现任何解决这个问题,

在我的应用我有写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]; 

} 
+0

你是Google吗?您向一个NSISLinearExpression对象发送了一个orientationChanged:消息,并且该类没有该名称的方法! –

+0

@HotLicks:是的,我已经在谷歌搜索'[NSISLinearExpression orientationChanged:]'但我没有找到任何这就是为什么我在这里提出问题。 – Optimistic

+0

我编辑了问题,请检查。 – Optimistic

回答

7

这么多次尝试我发现我没有删除观察员后,所以我必须在dealloc方法将其删除。

- (void)dealloc { 

    [[NSNotificationCenter defaultCenter] removeObserver:self]; 

} 
相关问题