日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

代码UITableView点击cell跳转

發布時間:2025/3/15 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 代码UITableView点击cell跳转 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • 首先,在tableViewController中設置好 代理和數據源方法:

    ?

    ?1 @interface FirstTableViewController ()<UITableViewDataSource,UITableViewDelegate>?

  • ?實現一系列的數據源方法:讓其顯示數據 例如 簡單顯示 幾行 : 1 #pragma mark 數據源方法 2 3 /** 4 5 * 一共有多少組數據 6 7 */ 8 9 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 10 11 { 12 13 return 2 ; 14 15 } 16 17 /** 18 19 * 第section組有多少行 20 21 */ 22 23 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 24 25 { 26 27 if (section == 0) { 28 29 return 2 ; 30 31 }else{ 32 33 return 4 ; 34 35 } 36 37 } 38 39 -(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 40 41 { 42 43 UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; 44 45 cell.textLabel.text = @"11"; 46 47 return cell ; 48 49 }

    ?

  • ?添加此方法實現跳轉。 1 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 2 3 { 4 5 SecondTableViewController *SVC = [[SecondTableViewController alloc]init]; 6 7 [self.navigationController pushViewController:SVC animated:YES]; 8 9 }

    ?

    注:點擊cell 后先創建個UIview 之后再用navigationController 推送出來

    這樣就可以成功通過點擊cell 創建新頁面了 實現跳轉了。

    ?

    ?

    ?

    ?

    ---------摘自百度經驗,有刪改,感謝原著

    ?

  • 轉載于:https://www.cnblogs.com/-yun/p/4375588.html

    總結

    以上是生活随笔為你收集整理的代码UITableView点击cell跳转的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。