UIAlertView with subview animating to new view crashes app

Posted by William on Stack Overflow See other posts from Stack Overflow or by William
Published on 2010-05-31T01:49:47Z Indexed on 2010/05/31 1:52 UTC
Read the original article Hit count: 370

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congratulations" message:message delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"View", nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(110, 100, 80, 80)];
NSString *imagePath = [NSString stringWithFormat:@"%@", [Array objectAtIndex:x]];
UIImage *bkgImg = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:imagePath ofType:@"png"]];
imageView.image = bkgImg;
[bkgImg release];
[alert addSubview:imageView];
[imageView release];
[alert show];
[alert release];    

That is the code that I am using to create the alert view. Currently, I have it set up so if the user presses one of the buttons, it will load up a new viewcontroller. It worked fine until I added a subview to the UIAlertView. Now, whenever it animates to the new screen, it just crashes the program. I am fairly new to iPhone development and any help would be appreciated.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone-sdk