0

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

五.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 (appDelegate4.globalParsingCompletedFlag==@"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];

}

五.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 表格视图。''

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

请尽可能尽快回复。

4

1 回答 1

0

您是否尝试过使用断点和调试器来逐步解决问题NSLog()与使用's相比,您将了解更多关于这种方式发生的事情。

于 2011-08-05T03:55:49.720 回答