麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

點擊TableView中某行進入下一級界面(Swift)

2019-11-14 20:03:45
字體:
來源:轉載
供稿:網友

  TableView這個控件在iOS的開發中非常的常見,他可以較好的展示一個層級結構。這里主要介紹,在點擊某個條目的時候,如何進行跳轉的下一個界面。以下是官方的關于這個跳轉如何去實現,和如何去傳遞數據的過程。

  

Storyboards make it easy to pass data from one scene to another via the PRepareForSegue:sender: method of the UIViewController class. This method is called when the first scene (the source) is about to transition to the next scene (the destination). The source view controller can implement prepareForSegue:sender: to perform setup tasks, such as passing information to the destination view controller about what it should display in its table view. Listing 3-1 shows one implementation of this method.

Storyboards利用func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!)將數據從一個界面傳輸到另外一個界面。這個函數在源界面切換到目標界面的時候會調用。所以在源View Controller中可以重載func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!)這個方法,在該方法內完成將數據傳送到目的View Controller。下面就是這個函數一般的實現方式。
(Objective-C)
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{if ([[segue identifier] isEqualToString:@"ShowDetails"]) { MyDetailViewController *detailViewController = [segue destinationViewController]; NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; detailViewController.data = [self.dataControllerobjectInListAtIndex:indexPath.row];} }


(Swift)

func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {

        if(segue.identifier == "ShowDetails"){

            var detailViewController:MyDetailViewController ! = segue.destinationViewController as MyDetailViewController

       var index = tableView.indexPathForSelectedRow()

            detailViewController.data = dataController[index!.row]

        }

}

 
A segue represents a one-way transition from a source scene to a destination scene. One of the consequences of this design is that you can use a segue to pass data to a destination, but you can’t use a segue to send data from a destination to its source. To solve this problem, you create a delegate protocol that declares methods that the destination view controller calls when it needs to pass back some data.

Segue是條從源界面到目標界面的一條路。你可以通過Segue將數據從源界面->目標界面。

 以上的過程是在tableViewCell與DetailView界面建立Segue連接的情況下,并且設置了Segue的identifer。

Segue是完全在Storyboard可以拖拽建立,比較簡單,關于如何建立Segue請網上查找下資料。

  


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: av不卡毛片 | 成人在线视频播放 | 久久精品国产99久久6动漫亮点 | 91一区二区三区久久久久国产乱 | 成人片免费视频 | 国产69精品久久久久9999不卡免费 | www.91pron| h视频在线观看免费 | 欧美日韩一 | 久久精品一二三区 | 黄色网址免费在线播放 | 国产毛片在线 | 在线男人天堂 | 毛片一区二区三区四区 | 日本中文视频 | 欧美一级黄色录像片 | 色综合视频 | 7777视频 | 久久久久久久.comav | 日韩伦理电影免费观看 | 国产成人精品区 | 成人短视频在线观看免费 | 久久av免费 | 成人一级免费视频 | 国产一级毛片高清视频完整版 | 中国黄色一级生活片 | 久久精品一区二区三区四区五区 | 成熟女人特级毛片www免费 | 精品久久久久久久久亚洲 | 久久艹艹艹 | 欧美日韩一区二区综合 | 精精国产xxxx视频在线野外 | 一级黄色毛片a | 水多视频在线观看 | 国产资源在线观看视频 | 久久亚洲视频网 | 欧美激情精品久久久久久久久久 | 一区国产在线观看 | 99欧美视频| 福利在线国产 | 久久久久久久亚洲视频 |