视图传值-跳转

本文详细介绍了在iOS开发中如何通过segue进行视图间的传值,并展示了如何使用UITableView选择行内容并传递给下一个视图。同时,文中还解释了如何利用UIStoryboard和navigationController实现视图跳转。

//向下个视图传值

#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)#> //(返回上一视图) 

转载于:https://www.cnblogs.com/guanliyang/p/3796335.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值