UITableVIewCell的设置(附标题/高度/右边的标识)

方法:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

//创建cell

UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];

//设置cell的图片

NSString *imageName = [NSString stringWithFormat:@"00%ld.png",indexPath.row + 1];

cell.imageView.image = [UIImage imageNamed:imageName];

//设置cell的主标题

NSString * text = [NSString stringWithFormat:@"产品-%ld",indexPath.row + 1];

cell.textLabel.text = text;

//设置cell的附标题, 它的显示跟创建cell时的style有关

// style = UITableViewCellStyleDefault :附标题不显示,图片显示

// style = UITableViewCellStyleValue1 :附标题与祝标题平行显示,图片显示

// style = UITableViewCellStyleValue2 :附标题显示,图片不显示

// style = UITableViewCellStyleSubtitle :附标题与主标题上下显示,图片显示

NSString *subtitle = [NSString stringWithFormat:@"产品-%ld很好",indexPath.row + 1];

cell.detailTextLabel.text = subtitle;

//设置右边的图标

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;

}

// 设置cell的高度(继承delegate的方法:不仅要<UITableViewDataSource, UITableViewDelegate>,还要把控制器跟tableview的dataSource连线)

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

return 70;

}

时间: 2024-08-30 05:36:49

UITableVIewCell的设置(附标题/高度/右边的标识)的相关文章

设置UILabel可变高度(根据文本内容自动适应高度)

@property(nonatomic)UILabel *showLabel; // 计算文本所占高度,计算出来之后设置label的高度 // 第一个参数:字体大小,字体大小/样式影响计算字体的高度 // 第二个参数:CGSize结构体,结构体中第一个参数表示宽度,宽度的设置影响计算文本的高度,很明显越宽,高度越小:结构体中第二个参数表示最大能有多高,比如我们写为100,那么即使文本高度计算出来是200, 这个方法也会返回100, 所以一般情况下我们把它写为MAXFLOAT, 表示能有多高返回多

博客园里设置个性标题

这段代码,主要用于给标题转换默认样式,其他的可以自行修改参考 /*标题*/ #cnblogs_post_body h2 { background: none repeat scroll 0% 0% rgb(43, 102, 149); border-radius: 6px 6px 6px 6px; box-shadow: 0px 0px 0px 1px rgb(95, 90, 75), 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: rgb(255, 2

js 获取滚动条的高度 以及 设置滚动条的高度

//设置窗口滚动条高度 function setScrollTop(top){ if(!isNaN(top))document.body.scrollTop = top; } //取窗口滚动条高度 function getScrollTop(){ var scrollTop=0; if(document.documentElement&&document.documentElement.scrollTop){ scrollTop=document.documentElement.scrol

文字在div中垂直居中的方法,设置div的高度height和行高line-height一致

文字在div中垂直居中的方法,设置div的高度height和行高line-height一致,如 .containerdiv{ height:60px; line-height:60px; }

Android 动态设置控件高度

TextView textView= (TextView)findViewById(R.id.textview); LinearLayout.LayoutParams linearParams =(LinearLayout.LayoutParams) textView.getLayoutParams(); //取控件textView当前的布局参数 linearParams.height = 20;// 控件的高强制设成20 linearParams.width = 30;// 控件的宽强制设成3

设置UINavigationController标题的属性

self.title = @"产品详情"; [self.navigationController.navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], NSForegroundColorAttributeName, [UIFont systemFontOfSize:20.f], NSFontAttributeName, nil]]; 可以

VBA在WORD中给表格外的字体设置为标题

使用VB可以将表外的字体设置标题字体实际操作如下: VB代码如下: Sub oliver_1() Selection.EndKey Unit:=wdStory '光标移到文末 For i = 1 To ActiveDocument.Tables.Count '有几个表格,下面操作就循环几次 With Application.Browser .Target = wdBrowseTable '插入点在表格中 .Previous '插入点移至前一张表格之前 End With Selection.Mov

在ScrollView中嵌套ListView时,需要根据内容来设置listView的高度

动态设置ListView的高度 public void setListViewHeightBasedOnChildren(ListView mListView) { ListAdapter listAdapter = mListView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View lis

安卓ListView 如何设置item的高度

安卓中的listview,设置其显示item布局的高度来设置item在listview中显示的高度是不可取的.如何设置item的高度? 分为两种情况: 1.有图片的情况: 有图片的情况比较简单,布局的大小将会由图片的大小来撑起,这是只需要调节图片的width和height即可. 2.无图片情况 无图片的情况我们可以用两种方式来确定大小 a.在布局中使用Android:minHeight="5dp",填上需要的最小高度,这个方便直接. b.如果是在自己写的Adapter中,那就可以在ge