私はこれ以上少し私の髪を引っ張ってきました。私は非常に単純なアプリケーションを作成しています、それは単にRSSフィードをダウンロードし、それをUINavigationControllerの中にあるUITableviewに表示します。それは私がモーダルビューを提示しているフィードをダウンロードしている間。DismissModalViewが動作しません
私のモーダルビューでは、私はUIImageViewとスピンするように設定されているUIActivityIndicatorViewを表示しています。私はASIHTTRequestを使用してフィードを非同期的に取得し、次に補完ブロックを使用して応答文字列を取得し、スピナーまたは失敗ブロックを停止してNSErrorを取得し、アラートビューを表示します。これはすべて完全に機能します。
私は、コンプリーションブロック内で呼び出されるテーブルビューからモーダルビューを閉じるプロトコルを作成しました。しかしモーダルビューは決して解雇されません!私はナビゲーションコントローラにプッシュしようとしましたが、まったく同じ問題が発生します。私は、モーダルビューのデリゲートをnilに設定しようとしましたが、まだ運がありません。
私はASIHTTPRequestデリゲートメソッドを使用してブロックなしでチェックしました。これは同じです。モーダルビューを表示しないと、テーブルビューは正常に表示されます。
すべてのアイデア?私はdeallocと未使用の関数だけでなく、すべてのtableviewデリゲートとデータソースメソッドをスキップしました。 ModalViewのための私の理解で
@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];
}
マット
回答ありがとうございましたが、役に立たなかったです。ダウンロードが非同期的に、したがって別のスレッドで実行されるため、問題がスレッドの問題である可能性があります。 –