gpt4 book ai didi

ios - 错误 [NSISLinearExpression orientationChanged :]: unrecognized selector sent to instance

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:39 27 4
gpt4 key购买 nike

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

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

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

滚动条.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];

}

最佳答案

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

- (void)dealloc {

[[NSNotificationCenter defaultCenter] removeObserver:self];

}

关于ios - 错误 [NSISLinearExpression orientationChanged :]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22086344/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com