storyboard传值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.


//得到点击的cell,sender是指触发跳转的那个控件,这里指的是点击的cell
UITableViewCell *cell = (UITableViewCell *)sender;

//通过当前被点击的cell得到点击位置
NSIndexPath *selectedIndexPath = [self.tableView indexPathForCell:cell];

Roster *roster = self.rosterArray[selectedIndexPath.row];

//得到要跳转的viewcontroller
ChatTableViewController *chatTableViewController = (ChatTableViewController *)[segue destinationViewController];

chatTableViewController.chatToRoster = roster;

}
文章目录
|