活动指示器从网址崩溃加载图片

时间:2012-03-29 17:48:45

标签: ios xcode uiactivityindicatorview

这在返回UIApplicationMain时崩溃了(argc,argv,nil,NSStringFromClass([AppDelegate class])); 并说SIGABRT 有什么想法发生了什么以及如何解决它?

这曾经在我之前工作过......当然是在ARC之前和之前的xcode版本中。感谢。

-(IBAction)forward:(id)sender
{
    [self->active removeFromSuperview];
    // Assign activity indicator to the pre-defined property (so it can be removed when image loaded
    self->active =  [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(195, 425, 25, 25)];    

    // Start it animating and add it to the view  
    [self->active startAnimating];  
    [self.view addSubview:self->active]; 

    [self performSelectorInBackground:@selector(loadImageInBackgroundNext) withObject:nil];
    /*
    ADBannerView *adView = [[ADBannerView alloc] initWithFrame: CGRectMake(0, 318, 320, 50)];
    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
    adView.delegate = self; 
    //adView.delegate = ADBannerViewDelegate;
    [self.view addSubview: adView];
    */
}

- (void) loadImageInBackgroundNext
{
    if(count == max) {
        count=1;
    } else {
        count=count+1;
    }

    // Create a pool
    // NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    // Retrieve the remote image
    NSURL * imgURL = [NSURL URLWithString:[NSString stringWithFormat: @"http://www.site.com/image1.png"]];

    NSData *imgData = [NSData dataWithContentsOfURL:imgURL];
    UIImage *img    = [[UIImage alloc] initWithData:imgData];

    // Image retrieved, call main thread method to update image, passing it the downloaded UIImage
    [self performSelectorOnMainThread:@selector(assignImageToImageView:) withObject:img waitUntilDone:YES];

    // clean up
    // [pool release];
 }

0 个答案:

没有答案