カスタム テーブルビュー セルのボタンを押した後、非同期操作を実行し、セレクターのコールバック呼び出しで次のようにします。
[self performSegueWithIdentifier:SEGUE_PURCHASE_SEGUE sender:self];
したがって、次のコールバックが呼び出されます。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
}
新しい画面のviewDidLoad and viewWillAppear
メソッドが既に呼び出されていることをログで確認できますが、次の画面はこの後数秒でのみ表示されます。
ここでどのような問題が発生する可能性がありますか?
コード:
-(void) moveToPurchaseScreen{
NSLog(@"view1 moveToPurchaseScreen");
[self performSegueWithIdentifier:SEGUE_PURCHASE_SEGUE sender:self];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"view1 prepareForSegue");
//
// BSPurchaseViewController *purchaseViewController = [segue destinationViewController];
// purchaseViewController.pngImage = [BSSharedObject getInstance].createdImage;
//// [[BSPopupManager getInstance]closeWaitingPopup];
//
//
// NSLog(@"2");
}
-(void)viewDidDisappear:(BOOL)animated{
NSLog(@"view1 DidDisappear");
}
2012-10-10 21:51:15.644 BarneyShop[4961:11603] view1 moveToPurchaseScreen
2012-10-10 21:51:15.646 BarneyShop[4961:11603] view1 prepareForSegue
2012-10-10 21:51:15.647 BarneyShop[4961:11603] view2 viewDidLoad
2012-10-10 21:51:15.648 BarneyShop[4961:11603] view2 viewWillAppear
2012-10-10 21:51:23.812 BarneyShop[4961:f803] view1 DidDisappear
編集2:
[purchase initPurchase: self withSelector:@selector(moveToPurchaseScreen)andProduct:product];
-(void) initPurchase:(id)object withSelector:(SEL)selector andProduct:(Product *)product{
[operationQueue cancelAllOperations];
NSInvocationOperation *downloadImageOperation = [[NSInvocationOperation alloc] initWithTarget:[BSImageDownloader getInstance] selector:@selector(downloadImageSync:) object:URL_DOWNLOAD_IMAGE];
NSInvocationOperation *createImageOperation = [[NSInvocationOperation alloc] initWithTarget:[BSImageCreator getInstance] selector:@selector(createImage:) object:product];
NSInvocationOperation *saveImageOperation = [[NSInvocationOperation alloc] initWithTarget:[BSImageSaver getInstance] selector:@selector(saveImageAsPng:) object:nil];
NSInvocationOperation *callbackOperation = [[NSInvocationOperation alloc] initWithTarget:object selector:selector object:nil];
[createImageOperation addDependency:downloadImageOperation];
[saveImageOperation addDependency:createImageOperation];
[callbackOperation addDependency:saveImageOperation];
[operationQueue addOperation:downloadImageOperation];
[operationQueue addOperation:createImageOperation];
[operationQueue addOperation:saveImageOperation];
[operationQueue addOperation:callbackOperation];
}