私のアプリケーションで2つのビューコントローラーを使用しています。 FirstViewControllerにボタンがあります。ボタンを選択すると、SecondViewControllerがプッシュされます。私はSecondViewControllerのtableViewを持っています。 NSUserDefaultsを使用せずにSecondViewControllerのtableViewで選択したインデックスのindexpath値をFirstViewControllerに渡す方法前もって感謝します。indexpathの値をFirstViewControllerに渡します。
1
A
答えて
2
プロトコルを使用します。代理人を使用して、親ビューに値を戻すことができます。
親ビューコントローラをコールバックするには、デリゲート(@Protocol)を使用する方が常に優れています。その上
簡単なチュートリアルでは、値を渡すhere
0
使用NSNotificationsを見つけることができます。
1
あなたは常にSecondViewControllerアクセスからFirstViewControllerを介してアクセスすることができます - FirstViewControllerがselectedRowInSecondController
という名前のプロパティがある場合、[のUIViewController parentController]例えば:それは変数のプロパティを作成する際に第二のViewControllerで
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
FirstViewController *firstViewController = [self parentController];
firstViewController.selectedRowInSecondController = [indexPath row];
}
1
を。
@property(nonatomic,readwrite)NSUInteger indexValue;
次いで
@synthesize indexValue= _indexValue;
この後firstviewcontrollerにsecondVctrのオブジェクトを作成します。
#import "secondViewcontroller.h"
@interface firstviewcontroller : UIViewController
@property(nonatomic,strong)secondViewcontroller *objsecondViewcontroller;
@synthesize objsecondViewcontroller =_objsecondViewcontroller;
次のコードは、ユーザーがそのイベントのボタンをタップしたときに挿入されます。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CountDown *controller = [[secondvctr alloc] initWithNibName:@"secondvctr" bundle:nil];
self.objsecondViewcontroller.indexValue=indexPath
[self.navigationController pushViewController:controller animated:YES];
}
関連する問題
- 1. UICollectionViewのindexPathの値
- 2. indexPathの値を表示する方法
- 3. メインレポートクリスタルにサブレポートの値を渡します。
- 4. 値渡し値渡し参照渡し
- 5. Swift prepareForSegueは、PrepForSegue経由でFirstViewController(テーブルビュー)にデータを渡すときに空の配列
- 6. [indexPath行]のEXC_BAD_ACCESS
- 7. アンカーでajaxに値を渡します。
- 8. UISearchDisplayControllerからself.tableview indexpathを取得するtableView indexpath
- 9. クエリパラメータの値のリストを渡します
- 10. rgbカラー値の数値行列をchartJSRadar()に渡します。
- 11. のUITableView indexPath部ロジック
- 12. indexPath調整iPhone
- 13. NSDictionaryにindexPathを格納する
- 14. UITableView.visibleCellsのindexpathを知るには?
- 15. スピナーの値を選択し、その値をアンドロイドのサーバに渡します
- 16. パラメータ渡し(値渡し)
- 17. sqlパラメータの値を渡してレポートをdevexpressにしますか?
- 18. 選択したラジオの値を次のページに渡します
- 19. フォームの値を取得し、SubmitでBootstrapモーダルに渡します。
- 20. Powershellは引数の値をパラメータに渡して返します。
- 21. ajax beginFormは経路の値とボタンの値を渡します
- 22. iOS indexPath is nil(カスタムアクセサリーイメージ)
- 23. UITableView indexPath null問題
- 24. accessoryButtonからのSegueのIndexPath
- 25. Sqlのヌル値列に値を渡す
- 26. UITablieViewCellのindexPathを取得する
- 27. asp.net mvcのView2のView1のテキストボックスに値を渡します。c#
- 28. リンゴの迅速slideoutMenu indexPath
- 29. UtilityアプリケーションのFlipSideViewControllerのUISegmentedControl値をmainviewcontrollerに渡します...
- 30. indexPath行を検出し、新しいビューコントローラを分割ビューコントローラにプッシュ