//向下个视图传值
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//你连接的 identifier 的内容
if ([[segue identifier] isEqualToString:@"ChoseMusic"]) {
// 点击行内容
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell* viewCell = [self.tableView cellForRowAtIndexPath:indexPath];
NSString* str = [[viewCell textLabel] text];
NSLog(@"--%@--", str);
// 传值
[[segue destinationViewController] setValue:str forKey:@"TheMusic"];
}
}
试图跳转
UIStoryboard *storyboard = self.storyboard;
//此identifier在storyboard上相应页面对应的设置里填写,必须保持一致
UIViewController *Identifier = [storyboard instantiateViewControllerWithIdentifier:@"ClockListIdentity"];
[self presentViewController:Identifier animated:YES completion:nil];
带navigation的
只能用push(进栈)self.navigationController pushViewController:<#(UIViewController *)#> animated:<#(BOOL)#> //(进入下一视图)
pop (出栈) self.navigationController popToViewController:<#(UIViewController *)#> animated:<#(BOOL)#> //(返回上一视图)
本文详细介绍了在iOS开发中如何通过segue进行视图间的传值,并展示了如何使用UITableView选择行内容并传递给下一个视图。同时,文中还解释了如何利用UIStoryboard和navigationController实现视图跳转。
1万+

被折叠的 条评论
为什么被折叠?



