美文网首页
iOS开发之使用segue跳转

iOS开发之使用segue跳转

作者: yytester | 来源:发表于2016-12-08 17:18 被阅读323次

    在开发多页面程序时,需要使用到跳转功能,例如从一个�列表tableview A的某个单元格,跳转到另一个列表界面tableview B.

    操作步骤:

    1. 在A类定义prepare(for segue:
        override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
            if (segue.identifier == "showDetailYangShi") {
                let indexPaths = self.tableView?.indexPathsForSelectedRows
                let indexPath = indexPaths![0]
                let event = self.tvs[indexPath.section * 1 + indexPath.row] as! Tv
                let detailVC = segue.destination as! DetailYangTableViewController
                detailVC.tv =  event
            }
    

    其中detailVC.tv = event将数据event传递到了tableview B里的变量tv.
    DetailYangTableViewController就是tableview B的类名.

    1. 在main.storyboard里,在A的单元格里引出"show"关系到列表tableview B.(一定要注意,必须是从单元格里引出线,而不是直接从A引出,否则点击单元格会无法跳转)

    相关文章

      网友评论

          本文标题:iOS开发之使用segue跳转

          本文链接:https://www.haomeiwen.com/subject/vfusmttx.html