2012-05-23 112 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]; 

} 
相關問題