2012-05-23 45 views
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:]:消息发送到释放的实例0x639a890 [切换处理2211] ”应用崩溃由于内存泄漏

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

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

更多信息,请!我哪一行崩溃?什么是'linksGallery'? – dasdom

+0

更改此行并检查 - > indicator.center = CGPointMake(100,200);可能是你失去了对alertForLoading的引用。如果它不工作评论NSThread线和检查。我希望在initializeParser方法中出现错误。 – Dee

+0

linksGallery是类名 –

回答

1

尝试使用把下面线在第一:

[super viewDidLoad]; 

的 “的dealloc()” 内的功能:

[super dealloc]; 

在所有版本的结尾。

希望这会帮助你。

0

该错误消息意味着linksGallery的实例已经被你给它发送消息“respondsToSelector”时被释放。为了调试这个尝试,当你释放它的时候也将它设置为null,那么它不会崩溃,尽管它可能不会做你想要的。

+0

我已更新问题 –

+0

这正是我所说的。您正在释放一个对象,然后尝试使用它。 – Mark

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]; 
} 

希望这将有助于

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]; 

} 
相关问题