日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【UIKit】UITableView 3

發布時間:2023/12/15 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【UIKit】UITableView 3 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

UITableView??代碼

?

【1】拖入一個UITableView

【2】將TableView的dataSource與控制器連接

【3】首先得遵循UITableView的數據源協議<UITableViewDataSource>

【4】加入圖標文件

【5】代碼

1.設置一共多少組,系統默認是1組,所以不寫的話就默認1組

#pragma mark 返回多少組 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {// 在這里默認是1,寫與不寫一樣return 1; }

2.返回多少行,這里返回9行

#pragma mark 返回一組多少行 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return 9; }

3.返回每一行的具體數據

  下表為箭頭樣式

UITableViewCellAccessoryCheckmark ??
UITableViewCellAccessoryDetailButton
UITableViewCellAccessoryDetailDisclosureButton ??
UITableViewCellAccessoryDisclosureIndicator ??
UITableViewCellAccessoryNone 表示沒有
#pragma mark 返回具體數據 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:nil];/************************設置左邊圖標*******************/// 1.取出第i行所使用的圖片名稱NSString *imageName=[NSString stringWithFormat:@"00%d.png",indexPath.row+1];// 2.cell.imageView.image=上面取得的image的名字cell.imageView.image=[UIImage imageNamed:imageName];/***********************設置主標題*********************/cell.textLabel.text=@"12312432";
// 設置子標題,需要在上面的UITableViewCellStyleDefault改為UITableViewCellStyleSubtitlecell.detailTextLabel.text=@"詳細描述"; //子標題內容為詳細描述// 設置cell箭頭樣式cell.accessoryType=UITableViewCellAccessoryCheckmark;return cell;}

?

4.設置每一行的行高

  1)加入代理

2)添加代理協議<UITableViewDelegate>

3)調整高度

#pragma mark- 調整每一行的高度,代理方法 -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {// 設置所有高度為70;return 60;// 也可以根據傳入的不同內容進行不同的高度設置// 行數越多,高度越高//return 40+indexPath.row*5; }

?

?

?

轉載于:https://www.cnblogs.com/madeininfi/p/3667495.html

總結

以上是生活随笔為你收集整理的【UIKit】UITableView 3的全部內容,希望文章能夠幫你解決所遇到的問題。

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