UITableView的cell一些设置
2015-11-04 14:38
411 查看
//1.cell取消选中效果 cell.selectionStyle = UITableViewCellSelectionStyleNone; //2.cell取消自带的下滑下效果 tableView.separatorStyle = UITableViewCellSeparatorStyleNone; //3.设置系统自带的cell右边的小箭头 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //4.点击后,过段时间cell自动取消选中 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ ………… //消除cell选择痕迹 [self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f]; } - (void)deselect { [self.tableview deselectRowAtIndexPath:[self.tableview indexPathForSelectedRow] animated:YES]; } //在UITableView里面,选择了某一个cell以后,点击立刻取消该cell的选中状态,可以使用如下方法: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //some functions ...... // 取消选中状态 [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; //或者 [tableView deselectRowAtIndexPath:indexPath animated:YES];// 取消选中 } 5.让tableView不能滑动 _tabelView.scrollEnabled = NO; 6.让tableView不现实滑动条 _tabelView.showsVerticalScrollIndicator = NO; 7.拿到某个cell [tableView cellForRowAtIndexPath:indexPath]; //8设置cell的背景 UIView *aView = [[UIView alloc] initWithFrame:cell.contentView.frame]; aView.backgroundColor=[UIColor colorWithHex:@"47a8ef"]; cell.selectedBackgroundView = aView; //9.自定义cell的image大小 CGSize itemSize; if (indexPath.row==0) { itemSize=CGSizeMake(25, 25); } else if (indexPath.row==3) { itemSize=CGSizeMake(20, 15); } else { itemSize=CGSizeMake(20, 20); } UIImage*ic; if (indexPath.row == _selectCellId) { ic=[UIImage imageNamed:selectImageArray[indexPath.row]]; } else { ic=[UIImage imageNamed:imageArray[indexPath.row]]; } UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0.0); CGRect imageRect=CGRectMake(0.0, 0.0, itemSize.width, itemSize.height); [ic drawInRect:imageRect]; cell.imageView.image=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
相关文章推荐
- iOS开发UITableViewCell滚动到特定的行数
- UI界面设计嘚吧嘚
- UILabel自适应高度和自动换行
- [leetcode] 96. Unique Binary Search Trees 解题报告
- 将UIview的image保存到本地的方法
- Request的getParameter和getAttribute方法的区别
- [Ocean Modelling for Begineers] Ch3. Basics of Geophysical Fluid Dynamics
- iOS小技巧-UITableView取消或设置cell的选中效果
- UISearchController的用法,搜索后点击进入下一页要特别注意 [self.searchController presentViewController:detailVC animated
- HDU 4441 【Splay】 Queue Sequence
- UIPageControl分页控件
- 由ligerUI到amazeUI+dataTable插件
- UIScrolloView的简单用法
- Android Stuido超全快捷键
- lazy懒加载(延迟加载)UITableView
- UITableview reloadData 无效
- 既然有了elasticsearch为什么还要用hadoop和spark呢?good question
- [LeetCode] Longest Increasing Subsequence
- Qt-Quick中设置组件风格、显示一张图片、在一行显示多张图片的方法、绘制图片方法...
- iOS开发笔记--UIView中的坐标转换