UIImageView initWithCoder - 无法识别的选择器发送到实例... iOS 5 beta SDK

发布于 2024-11-29 01:39:14 字数 1644 浏览 3 评论 0 原文

如果已经有人问过,我很抱歉,但问题来了:

我最近将我的 SDK 更新到了 iOS 5 beta。我的应用程序在新模拟器上构建并运行得非常好,但是当我尝试将部署目标更改为旧版 iOS (4.3) 时,应用程序在尝试使用 UIActivityIndi​​catorView< 时立即崩溃/strong> 控制(模拟器和设备)。我在一个非常简单的加载视图中使用 UIActivityIndi​​catorView ,该视图仅由 ViewUIActivityIndi​​catorView 组成。

当我从该视图中删除 UIActivityIndi​​catorView 控件时,该视图工作正常,但是应用程序在加载其他视图(带有活动指示器和图像)时崩溃。所以,长话短说:应用程序在 iOS 5 环境中运行良好,但在较旧的 iOS 版本上运行时图像和活动指示器会使其崩溃。有什么想法吗?

提前致谢!

编辑

我添加一些代码只是为了向大家展示我如何使用该视图。它实际上并不多,并且 LoadingViewController 本身绝对没有自定义代码(所有控件都在笔尖中)。

if(!self.loadingScreen){
    self.loadingScreen = [[LoadingViewController alloc] initWithNibName:@"LoadingViewController" bundle:nil];
}
[self.view addSubview:loadingScreen.view];

异常消息实际上并没有说太多,但你可以看一下:

0   CoreFoundation                      0x017bd5a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x01911313 objc_exception_throw + 44
2   CoreFoundation                      0x017bf0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3   CoreFoundation                      0x0172e966 ___forwarding___ + 966
4   CoreFoundation                      0x0172e522 _CF_forwarding_prep_0 + 50
5   UIKit                               0x00f8e9fd UINibDecoderDecodeObjectForValue + 2592
6   UIKit                               0x00f8f6ac -[UINibDecoder decodeObjectForKey:] + 398
7   UIKit                               0x00d75db0 -[UIImageView initWithCoder:] + 97

I'm sorry if it has already been asked, but here comes the problem:

I've recently updated my SDK to iOS 5 beta. My app builds and runs perfectly fine on the new simulator, but when I try to change the Deployment Target to the older iOS (4.3), the app crashes instantly when it tries to use UIActivityIndicatorView control (both simulator and device). I'm using the UIActivityIndicatorView in a really simple loading view consisting only of a View and UIActivityIndicatorView.

When I remove UIActivityIndicatorView control from that view, the view works fine, BUT the app crashes while loading other views (with activity indicators and images). So, the long story short: app works fine in the iOS 5 environment, but images and activity indicators crash it while running it on older iOS versions. Any ideas?

Thanks in advance!

EDIT:

I'm adding some code just to show you guys how I'm using the view. It's really not much and the LoadingViewController itself has absolutely no custom code (all controls are in the nib).

if(!self.loadingScreen){
    self.loadingScreen = [[LoadingViewController alloc] initWithNibName:@"LoadingViewController" bundle:nil];
}
[self.view addSubview:loadingScreen.view];

The exception message doesn't actually say much more, but here you go:

0   CoreFoundation                      0x017bd5a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x01911313 objc_exception_throw + 44
2   CoreFoundation                      0x017bf0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3   CoreFoundation                      0x0172e966 ___forwarding___ + 966
4   CoreFoundation                      0x0172e522 _CF_forwarding_prep_0 + 50
5   UIKit                               0x00f8e9fd UINibDecoderDecodeObjectForValue + 2592
6   UIKit                               0x00f8f6ac -[UINibDecoder decodeObjectForKey:] + 398
7   UIKit                               0x00d75db0 -[UIImageView initWithCoder:] + 97

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

嘿看小鸭子会跑 2024-12-06 01:39:14

我遇到了同样的问题,刚刚找到了解决方案。
我的 UIActivityIndi​​cator 已添加到 xib 文件中。我已将其从 xib 中删除并通过代码创建它(activityIndi​​cator = [[UIActivityIndi​​catorView alloc] initWithActivityIndi​​catorStyle:...)。

现在一切正常了,可以用了!

我希望这会对您有所帮助。

I had the same problem and just found a solution.
My UIActivityIndicator was added into a xib file. I have removed it from the xib and have created it by code (activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:...).

All is ok now, it works !

I hope this will helps you.

豆芽 2024-12-06 01:39:14

我无法打开网址 https://devforums.apple.com/message/507796#507796 ....但我认为你可以为 UIImage 类创建一个类别,如下所示:

@implementation UIImage (Coder)

- (id)initWithCoder:(NSCoder *)aCoder
{
     return nil;
}

@end

I can't open URL https://devforums.apple.com/message/507796#507796.... but I think you can make a category for UIImage class, like this:

@implementation UIImage (Coder)

- (id)initWithCoder:(NSCoder *)aCoder
{
     return nil;
}

@end
梦初启 2024-12-06 01:39:14

按照 smith324 的建议,我开始浏览 Apple 开发论坛,以了解我是否做错了什么或者 SDK 中是否存在错误。事实证明,最新版本中有一个令人讨厌的错误,导致 UIImages、UIActivityIndi​​cators 等崩溃,就像我的情况一样。好消息是,实际上有一个解决方法,您可以在这里找到它: https://devforums.apple.com/message/507796#507796

感谢大家的帮助!

编辑:

如果您无法访问该链接,这是建议的答案:

@implementation UIImage (initWithCoder)

- (id)initWithCoder:(NSCoder *)aDecoder
{
     return nil;
}

@end

Following smith324's advice I started to browse Apple dev forums to find out if I'm doing something wrong or if there's a bug in the SDK. It turns out, that there's a nasty bug in the latest release crashing UIImages, UIActivityIndicators etc. just like in my case. Good news is, there actually is a workaround and you can find it here: https://devforums.apple.com/message/507796#507796

Thanks everyone for your help!

EDIT:

If you can't access the link, this is the suggested answer:

@implementation UIImage (initWithCoder)

- (id)initWithCoder:(NSCoder *)aDecoder
{
     return nil;
}

@end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文