Hi all,
the following code crashes the application, and I don't know why. It crashes irregularly, that means that sometimes the imageview can be shown for example 30 times when a row is clicked, sometimes it chrashes the second time when I select a row.
FYI: the activity indicator,the action sheet and the variable imageNr are defined globally and will be initialized in the viedDidLoad method.
Thanks in advance for your advices.
Sean
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
imageNr = indexPath.row + 1;
activityLoadView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(-17.5, -11, 35, 35)];
activityLoadView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
activityLoadView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
actionSheetLoadView = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
actionSheetLoadView.actionSheetStyle = UIBarStyleBlackOpaque;
[actionSheetLoadView setMessage:[NSString stringWithFormat:@"\n\n\n\n\n\n\n\n\n\n\n\n\nLoading image ..."]];
[actionSheetLoadView addSubview:activityLoadView];
[actionSheetLoadView showInView:self.view];
[actionSheetLoadView setBounds:CGRectMake(0,0,320,720)];
[activityLoadView performSelector:@selector(startAnimating) withObject:nil afterDelay:0.1];
[self performSelectorInBackground:@selector(showImageView) withObject:nil];
}
- (void)showImageView
{
[self setViewInfo];
[self.navigationController pushViewController:imageViewController animated:YES];
[activityLoadView performSelector:@selector(stopAnimating) withObject:nil afterDelay:0.1];
[actionSheetLoadView dismissWithClickedButtonIndex:0 animated:YES];
[activityLoadView release];
[actionSheetLoadView release];
}