She*_*lam 5 iphone cocoa-touch exc-bad-access objective-c ipad
我启用了NSZombie,当我运行我的应用程序时,我在控制台中收到以下消息:
*** -[UIViewAnimationState release]: message sent to deallocated instance 0xf96d7e0
Run Code Online (Sandbox Code Playgroud)
这是执行动画的方法
-(void)loadAvatar:(STObject*)st
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
avatar.alpha = 0;
avatar.frame = avatarRectSmall;
avatar.image = [ImageCache getMemoryCachedImageAtUrl:st.avatar_url];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.50];
avatar.frame = avatarRectNormal;
[avatar setAlpha:1];
[UIView commitAnimations];
[pool release];
pool = nil;
}
Run Code Online (Sandbox Code Playgroud)
我有时候并不会总是崩溃.我想知道什么是发布的?
Ada*_*ach 15
你有一个自动释放池,提示我问,这是一个单独的线程吗?如果答案是肯定的那么你就不能在那里做UIView.UIKit不是线程安全的.您可以执行其他操作,例如计算位置或更新您稍后放在屏幕上的图像,但任何用户界面都必须在主线程中进行.
您可以使用非常简单的安全检查功能,所有功能都可以通过UI执行:
-(void)functionModifyingUIelements:(id)object
{
// fire itself in main thread if it is not in it already
if (![[NSThread currentThread] isMainThread]) {
[self performSelectorOnMainThread:@selector(functionModifyingUIelements:) withObject:object waitUntilDone:NO];
return;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3340 次 |
最近记录: |