The application crashes very rarely. One time it crashed, and I got the following report:
[UIViewAnimationState release]:message sent to deallocated instance
I am not able to find where is this used. I do not use any animations in my code. What can be the reason for the crash?
this is the code i suspect where it is crashing
-(void)showMessageSend开发者_JS百科ingIndicator
{
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
self.av1=[[UIAlertView alloc] initWithTitle:@"Sending Message, please wait..." message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
UIActivityIndicatorView *ActInd=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[ActInd startAnimating];
[ActInd setFrame:CGRectMake(125, 60, 37, 37)];
[self.av1 addSubview:ActInd];
[self.av1 show];
[pool release];
return;
}
Firstly, you are setting av1 to a retained object. Replace this line with something like this:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sending Message, please wait..." message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
self.av1 = alert;
[alert release];
Secondly, you never release ActInd. Add [ActInd release] before [pool release]. This is safe because av1 retains it when you call addSubview:
On a side node, why the NSAutoreleasePool? You typically need those on a separate thread, but showing an activity indicator should be done on the main thread.
And also, if you want to follow any conventions, you should replace ActInd with actInd.
加载中,请稍侯......
精彩评论