受信viewController(この場合はSecondTableViewControllerと呼びます)でプロパティ(selectedText - NSStringなど)を宣言します。ここでは、コードは次のようになります。SecondTableViewController.hで
:SecondTableViewController.mで
@interface SecondTableViewController : UITableViewController {
}
@property(nonatomic, strong) NSString *selectedText;
:
あなたFirstTableViewController.mで
@implementation SecondTableViewController
@synthesize messageDetail;
:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure we are dealing with the proper Segue
if ([segue.identifier isEqualToString:@"idOfMySegue"]) {
SecondTableViewController *svc = segue.destinationViewController;
svc.selectedText = myVarValue; // This can be got from either setting another var in the tableviewcontroller or by just passing the entire object at the selected index of the NSIndexPath.row (if you are populating the tableview with an array. Note you would change the object type of the passed along object from an NSString to whatever the other object is.
}
}
prepareForSeque方法がされあるビューから別のビューにデータまたはオブジェクトを渡します。
唯一の問題は、prepareForSegue(prepareForSegueが入力されたクラス)内のクラスプロパティにアクセスできないことです。 – blake305
FirstTableViewController.mファイルのSecondTableViewControllerへの参照を含める限り、アクセスできます。 –
あなたが今持っているものを私に送ってください。私はあなたが問題を理解するのを手伝ってくれるでしょう。 –