我尝试使用unwind方法在另一个视图中返回行的值(从表中) 但是第一个viewController中的值catch为null。
这是FirstViewController中的代码
- (IBAction)retrievePremadeMessage:(UIStoryboardSegue *)segue;(h)
- (IBAction)retrievePremadeMessage:(UIStoryboardSegue *)segue
{
PreStoredMessagesTableViewController *cc = segue.sourceViewController;
self.textViewMsg = [[UITextView alloc] init];
self.textViewMsg.text = cc.valeurCell;
NSLog(@"cell selected: %@", cc.valeurCell);
}
这是第二个ViewController
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Retrieve the value of cell selected
self.valeurCell = [NSString stringWithFormat:@"%@", [tableView cellForRowAtIndexPath:indexPath].textLabel.text];
}
谢谢
答案 0 :(得分:0)
在这种方法中:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Retrieve the value of cell selected
self.valeurCell = [NSString stringWithFormat:@"%@", [tableView cellForRowAtIndexPath:indexPath].textLabel.text];
}
添加:
[self performSegueWithIdentifier:@"identifier" sender:[NSString stringWithFormat:@"%@", [tableView cellForRowAtIndexPath:indexPath].textLabel.text]];
然后你可以这样做:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSString *stringPassedIn = id;
}