iPAD模拟器和设备之间的区别
我在开发 iPad 应用程序(语言:C++/Objective-C)时有一个奇怪的行为:碰巧在模拟器中一切正常,换句话说,应用程序成功运行,同时实现程序进入设备时,我收到了难以理解的 EXC_BAD_ACCESS。
这是我在 Obj-C 环境中的一段代码:
-(void) BindTexture:(unsigned char*)TexBuff {
// TexBuff is a fild of a pointer list, containing data prevoisly saved
UIImager *texImg = (UIImage*)TexBuff;
CGImageRef imageRef = [texImage CGImage];
....
.... {so on} ...
}
设备在调用 CGImageRef 之前卡住了。
奇怪之处在于模拟器和设备之间的差异。
你有什么想法吗?
I've a strange behaviour developing an iPad application (languages: C++/Objective-C): it happens that in the simulator everything it's ok, in other words the application run successfully, meanwhile when implementing the program into the device I receive an unintelligible EXC_BAD_ACCESS.
This is a chunk of my code in the Obj-C environment:
-(void) BindTexture:(unsigned char*)TexBuff {
// TexBuff is a fild of a pointer list, containing data prevoisly saved
UIImager *texImg = (UIImage*)TexBuff;
CGImageRef imageRef = [texImage CGImage];
....
.... {so on} ...
}
The device stucks before the call CGImageRef.
The oddities is the difference between Simulator and the Device.
Have you some idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在将 unsigned char* 转换为 UIImage* - 这不是一件好事,并且可能是导致 EXC_BAD_ACCESS 的原因。
TexBuff 应该是你的原始数据数组吗?如果是这样,请参阅这篇文章了解如何将原始数据(例如 RGBA 数据)转换为 CGImage:
在 Objective-C++ Cocoa 中将 RGB 数据转换为位图
You are casting an unsigned char* to a UIImage* - this is not a good thing to do and is likely the cause of your EXC_BAD_ACCESS.
Is TexBuff supposed to be your raw data array? If so, see this post for how to convert raw data (RGBA data for example) into a CGImage:
Converting RGB data into a bitmap in Objective-C++ Cocoa