0
- (void)viewDidLoad {

    webCollectionOnScroller=[[NSMutableArray alloc] init];
    scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 370, 320, 94)];
    scroll.pagingEnabled = YES;
    currentWeb=0;
    globali=0;
    firstTime=0;
    [loadingWeb startAnimating];
    alertForLoading = [[UIAlertView alloc] initWithTitle:@"Loading..." message:@"link is being loaded.\n Please wait!" delegate:self cancelButtonTitle:@"Back" otherButtonTitles:nil];
    [alertForLoading show];
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    // Adjust the indicator so it is up a few pixels from the bottom of the alert
    indicator.center = CGPointMake(alertForLoading.bounds.size.width / 2, alertForLoading.bounds.size.height - 100);
    [indicator startAnimating];
    [alertForLoading addSubview:indicator];
    [NSThread detachNewThreadSelector:@selector(initializeParser)toTarget:self withObject:nil];
    [super viewDidLoad];
}

这是控制台错误“-[linksGallery respondsToSelector:]: message sent to deallocated instance 0x639a890 [Switching to process 2211]”

当我在主视图上评论发布声明时它不会崩溃

-(IBAction) goToLinks{
    linksGallery *showLinks=[[linksGallery alloc] initWithNibName:@"linksGallery" bundle:nil];
    [self.navigationController pushViewController:showLinks animated:YES];
        //[showLinks release];
}
4

4 回答 4

1

尝试首先放置以下行:

[super viewDidLoad];

在“dealloc()”函数内部:

[super dealloc];

在所有版本结束时。

希望这会帮助你。

于 2012-05-23T12:11:43.667 回答
0

该错误消息意味着 linksGallery 的实例在您向其发送消息“respondsToSelector”时已被释放。要调试它,请尝试在释放它时将其设置为 null,这样它就不会崩溃,尽管它可能也不会做你想做的事。

于 2012-05-23T12:02:58.997 回答
0

使您的 ViewDidLoad 看起来像这样:

- (void)viewDidLoad {

[super viewDidLoad];

webCollectionOnScroller=[[NSMutableArray alloc] init];
scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 370, 320, 94)];
scroll.pagingEnabled = YES;
currentWeb=0;
globali=0;
firstTime=0;
[loadingWeb startAnimating];
alertForLoading = [[UIAlertView alloc] initWithTitle:@"Loading..." message:@"link is being loaded.\n Please wait!" delegate:self cancelButtonTitle:@"Back" otherButtonTitles:nil];
[alertForLoading show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alertForLoading.bounds.size.width / 2, alertForLoading.bounds.size.height - 100);
[indicator startAnimating];
[alertForLoading addSubview:indicator];
[NSThread detachNewThreadSelector:@selector(initializeParser)toTarget:self withObject:nil];

}
于 2012-05-23T12:34:46.650 回答
0

试试下面的代码

-(IBAction) goToLinks{
    linksGallery *showLinks=[[linksGallery alloc] initWithNibName:@"linksGallery" bundle:nil];
    [self.navigationController pushViewController:[showLinks mutableCopy] animated:YES];
    [showLinks release];
}

或者

-(IBAction) goToLinks{
    linksGallery *showLinks=[[[linksGallery alloc] initWithNibName:@"linksGallery" bundle:nil] autorelease];
    [self.navigationController pushViewController:showLinks animated:YES];
    //[showLinks release];
}

希望这会有所帮助

于 2012-05-23T12:18:29.260 回答