0

タスクを実行するビューがあります。タスクが完了すると、アクティビティ インジケーターが非表示になります。アクティビティが完了したときにユーザーを別のビューに送り、失敗した場合はユーザーにエラーを表示します。これまでのところ、If Else ステートメントを使用して成功アラートまたはエラー アラートを出しています。クリックするボタンなどはありません。アクティビティが完了すると、ユーザーは途中でいくつかの変数を渡して別のビューに送られます。

完了後にユーザーを別のビューに送信するにはどうすればよいですか?

4

3 に答える 3

1

ナビゲーションコントローラーを使用する場合:

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

ストーリーボードについては、ドキュメントでメソッドを調べてください。

于 2013-02-17T20:01:01.630 に答える
1

AlexWienの答えを少し詳しく説明するには...

  • 完了後にユーザーが移動するビュー コントローラーまたはテーブル ビュー コントローラー クラスを作成します。
  • 渡すデータのプロパティをいくつか作成します。

@protocol UpdatePricesDelegate;

@interface NXUpdatePricesViewController : UITableViewController

@property (strong, nonatomic)   NSArray *calculationProducts;
@property (strong, nonatomic)   NSArray *filteredCalculationProducts;

@property (weak, nonatomic)     id<UpdatePricesDelegate>delegate;

@end

@protocol UpdatePricesDelegate <NSObject>

- (void)updatePricesController:(NXUpdatePricesViewController *)controller didUpdateCalculationProducts:(NSArray *)calculationProducts;

@end

  • コントローラーを表示する準備ができたら (おそらく If/Else ステートメントで)、クラスをインスタンス化し (#import "MyClassName.h" を忘れないでください)、渡したい変数にプロパティを設定します。
  • クラスをモーダルに表示します (例にはナビゲーション コントローラーが含まれます)。ビューをプッシュする場合は、ナビゲーション コントローラーを使用します。

NXUpdatePricesViewController *updatePricesController = [[NXUpdatePricesViewController alloc] initWithStyle:UITableViewStyleGrouped];
updatePricesController.delegate = self;
updatePricesController.calculationProducts = self.calculationProducts;

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:updatePricesController];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;


[self.navigationController presentViewController:navigationController animated:YES completion:nil];

NXCalculationViewController *calculationController = [[NXCalculationViewController alloc] init];
calculationController.calculation = calculation;
[self.navigationController pushViewController:calculationController animated:YES];
于 2013-02-18T05:07:32.087 に答える
0

このメソッドを使用して変数を他のビューに渡すとともに、実際に機能させました。

DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailView"];
[detail setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
detail.videoURL = outputURL;
于 2013-02-21T11:16:29.630 に答える