Uitableview 解雇莫达维不工作

Uitableview 解雇莫达维不工作,uitableview,modal-dialog,viewcontroller,Uitableview,Modal Dialog,Viewcontroller,我一直在为这件事发脾气。我正在创建一个非常简单的应用程序,它只需下载一个rss提要并将其显示在UITableview中,UITableview位于UINavigationController中。在下载feed的同时,我展示了一个模态视图 在模式视图中,我显示一个UIImageView和一个设置为旋转的UIActivityIndicatorView。我使用ASIHTTRequest异步获取提要,然后使用完成块获取响应字符串并停止微调器,或者使用失败块获取NSError并显示警报视图。这一切都很完美

我一直在为这件事发脾气。我正在创建一个非常简单的应用程序,它只需下载一个rss提要并将其显示在UITableview中,UITableview位于UINavigationController中。在下载feed的同时,我展示了一个模态视图

在模式视图中,我显示一个UIImageView和一个设置为旋转的UIActivityIndicatorView。我使用ASIHTTRequest异步获取提要,然后使用完成块获取响应字符串并停止微调器,或者使用失败块获取NSError并显示警报视图。这一切都很完美

然后,我创建了一个协议,从tableview中取消模式视图,它在completion块中调用。但是模态视图永远不会被忽略!我试着将它推入导航控制器,但同样的问题也发生了。我甚至尝试过将模态视图委托设置为nil,但仍然没有成功

我已经使用ASIHTTPRequest委托方法在没有块的情况下对其进行了检查,结果是一样的,如果我没有显示模式视图,则表视图将正常显示

有什么想法吗?我已经跳过了所有的tableview委托和数据源方法以及dealoc和任何未使用的函数

@interface MainTableViewController () 
-(void)loadModalView;
@end


@implementation MainTableViewController
@synthesize tableView;
@synthesize modalView;

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{

   [super loadView];
tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
[self.view addSubview:tableView];

   [self loadModalView];


}

-(void)loadModalView
{
    modalView = [[ModalViewController alloc]init];
    modalView.delegate = self;
    [self presentModalViewController:modalView animated:NO];

}


//Modal View Delegate
-(void)downloadComplete
{
modalView.delegate = nil;
[self dismissModalViewControllerAnimated:NO];



}


@end 


@interface ModalViewController ()


- (void)loadView
{
[super loadView];

backgroundImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 460)];

[self.view addSubview:backgroundImage];

spinner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.frame = CGRectMake(160, 240, spinner.bounds.size.width, spinner.bounds.size.height);
spinner.hidesWhenStopped = YES;
[self.view addSubview:spinner];
[spinner startAnimating];


NSString* urlString = FEED_URL;
NSURL* url = [NSURL URLWithString:urlString];

ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:url];
[request setCompletionBlock:^{
    // Use when fetching text data
    NSString *responseString = [request responseString];
    [spinner stopAnimating];
    [delegate downloadComplete];
    // Use when fetching binary data

}];
[request setFailedBlock:^{
    NSError *error = [request error];
    UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"Error" message:error.description delegate:self cancelButtonTitle:@"Continute" otherButtonTitles: nil];
    [alert show];
    [alert release];
}];
[request startAsynchronous];



}

据我所知,马特。。你的解决方案相当复杂。。 如果MainTableViewController类是 下载提要的人。。对于ModalView,它将仅作为活动指示器,并在下载后关闭。。 因此,在MainTableViewController loadview中:

- (void)loadView
{
  NSString* urlString = FEED_URL;
  NSURL* url = [NSURL URLWithString:urlString];

  ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:url];
  [request startAsynchronous];
  //after starting the request show immediately the modalview
  modalView = [[ModalViewController alloc]init];
  [self presentModalViewController:modalView animated:NO];

  [request setCompletionBlock:^{
    // Use when fetching text data
    NSString *responseString = [request responseString];
    //then when it is complete dissmiss the modal
    [modalView dismissModalViewControllerAnimated:NO];

    // Use when fetching binary data
  }];
  [request setFailedBlock:^{
    NSError *error = [request error];
    UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"Error" message:error.description delegate:self cancelButtonTitle:@"Continute" otherButtonTitles: nil];
    [alert show];
    [alert release];
  }];


}
我没有在我的项目中使用块,但我认为它也会起同样的作用。。
我还使用一个普通的UIActivityIndicatorView作为子视图,而不是ModalView。。很遗憾,我现在无法在这里测试代码。。但我可以稍后再检查,不过解决此错误的唯一方法是同步下载数据并将下载视图推送到导航堆栈上。虽然不理想,但效果很好。

谢谢你的回答,但没有帮助。我觉得问题可能是线程问题,因为下载是异步执行的,因此在不同的线程上执行。