0

我有一个tableview(文件名-5.m),它工作正常,并正确显示tableview中的数据。当用户选择一行时,它会在同一屏幕上添加一个显示进度指示器的子视图。添加子视图后,它启动一个后台线程,解析HTML数据并将其添加到SQLite3数据库。后台线程,SQLIte数据插入,HTML解析都工作正常。现在,当它完成时,它会在removeProgressInd方法中返回到five.m,该方法将删除进度指示器并导航到新的表视图(文件名TitleOnly.m)。它可以成功返回,因为我可以看到来自removeProgressInd方法的所有NSLog消息。但是代码不会停止进度指标,也不会移动到新的tableview。代码运行没有任何错误。我试图在viewDidLoad和viewDidAppear中运行相同的代码,而不是removeProgressInd,但我只看到NSLog消息。这是我的代码。从后台线程返回代码不工作

Five.m - 的tableview DidSelelectRow

{ 
    // start ProgressInd 
    [self.view addSubview:self.progressInd]; 
     // shows progress Indicator on screen when I run my app in simulator 

    // start Parsing Calculation in Background thread 


if ([email protected]"0") 
{ 
    NSLog(@"starting backgroung thread- parsing calulation- because flag==0"); 

    ParsingCalculation *parsC = [[ParsingCalculation alloc] init]; 
    [queue addOperation:parsC]; 
    [parsC performSelectorInBackground:@selector(main) withObject:nil]; 

    [parsC release]; 
    //successfully starts parsing in background 
    } 
} 

ParsingCalculation.m文件代码

- (void)main { 


NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 
//your code to do the operations... 

appDelegate5=[[[UIApplication sharedApplication] delegate] retain]; 


NSLog(@"Now we are in ParsingCalulation.m"); 

    //resultsFromURL is another method in parsingCalulation.m that does all parsing successfully 
[self resultsFromURL:appDelegate5.globalLocationURL]; 

NSLog(@"Now we are moving back in Five.m -calling function removeProgressInd "); 

[[Five shared] performSelectorOnMainThread:@selector(removeProgressInd) 
            withObject:nil 
           waitUntilDone:YES]; 

//it returns back to five.m successfully after finishing HTML Parsing 


[pool release]; 

} 

Five.m - removeProgressInd方法

-(void) removeProgressInd{ 

NSLog(@"Now we are back in Five.m -in function removeProgressInd "); 


     //remove progressInd from superview as parsing calculation has been completed 


     [progressInd stopAnimating]; 

     [self.progressInd removeFromSuperview]; 


//move to TitleOnly.m tableview   

     NSLog(@"navigate to TitleOnly "); 

    TitleOnly *newView = [[TitleOnly alloc] initWithNibName:@"TitleOnly" bundle:nil]; 

    [self.navigationController pushViewController:newView animated:YES]; 

    [newView release]; 


} 

我可以在控制台中看到“导航到TitleOnly”消息而没有任何错误,这意味着它成功运行了[progressInd stopAnimating]和[self.progressInd removeFromSuperview]命令,没有任何错误,因为这些命令就在此NSLog消息之前。但它不会从屏幕上删除进度指标。同样,它不显示TitleOnly tableview。 ''

我该如何解决它?哪里有问题?我究竟做错了什么?

请尽快回复。

回答