草庐IT

UitableviewCell

全部标签

ios - UITableviewcell cell.textlabel.text 在滚动 tableview 时重复?如何避免 cell.textlabel.text 重复?

-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{staticNSString*CellIdentifier=@"Cell";UITableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:CellIdentifier];cell.selectionStyle=UITableViewCellSelectionStyleBlue;if(cell==nil){cell=[[UITa

ios - 使用 rxswift 禁用 UITableViewCell 编辑模式

我使用rxswift将我的数据源绑定(bind)到tableview,但默认情况下单元格在我这样做时是可编辑的,我如何禁用该功能?这里是我得到的tableview的例子: 最佳答案 你在使用RxDataSources吗?您可以按照以下方式配置您的数据源dataSource.canEditRowAtIndexPath={dataSource,indexPathinfalse} 关于ios-使用rxswift禁用UITableViewCell编辑模式,我们在StackOverflow上找到一

ios - UITableViewCell 中的 Nib 文件加载的 UIView 不拉伸(stretch)

我有一个可通过nib/xib文件重用的UIView。我想加载它并填充一个UITableViewCell,它将在一个自调整大小的UITableView中使用。全部具有自动布局。大多数工作正常,但似乎加载的UIView使用围绕它添加的约束来缩小UITableViewCell的contentView。这对高度有好处,但我不希望宽度如此。忽略下面的灰色单元格,这只是一个选中的单元格。publicfunctableView(_tableView:UITableView,cellForRowAtindexPath:IndexPath)->UITableViewCell{letcellId="Row

ios - UITableViewCell 在 iOS 11 中使用 separatorInset 隐藏分隔符失败

这是我在iOS11之前用于隐藏单个UITableViewCell分隔符的代码:-(void)tableView:(UITableView*)tableViewwillDisplayCell:(UITableViewCell*)cellforRowAtIndexPath:(NSIndexPath*)indexPath{if(indexPath.row==0){//Removeseparatorinsetif([cellrespondsToSelector:@selector(setSeparatorInset:)]){[cellsetSeparatorInset:UIEdgeInsets

ios - iPhone UITableView 在重用 UITableViewCell 时按下删除按钮后缺少披露按钮

我有一个iPhoneUITableView显示自定义UITableViewCell,在其右侧显示披露按钮图标。当我滑动单元格时,披露按钮会自动替换为红色的“删除”按钮。如果我按下“删除”按钮,该行将从表格中删除,但随后会发生一些奇怪的事情。当我滚动表格并且删除的单元格被重新使用时,数据被正确加载但披露按钮丢失。我尝试在prepareForReuse方法中重置按钮,但没有成功。我不明白我错过了什么,因为行为似乎与邮件应用程序相同,因此iPhone操作系统应该原生支持它。顺便说一句:UITableViewCell是从NIB加载的。 最佳答案

iphone - 如何在 UITableView (UITableViewCell) 中使用 UITextField 实现类似的 UI?

我希望在UITableViewCell(在UITableView中)中使用UITextField来模仿以下UI。我是MonoTouch的新手,我似乎无法弄清楚代码会是什么样子。 最佳答案 这很简单。只需向单元格添加一个没有背景颜色的UITextField。在您的cellForRowAtIndexPath方法中添加以下代码。UITextField*inputText=[[UITextFieldalloc]initWithFrame:CGRectMake(10,10,280,22)];inputText.textAlignment=UI

ios - 配置自定义 UITableViewCell 时如何传递参数

我有一个自定义的UITableViewCell,我们称它为CustomCell。我只需要在创建它时传递一个参数,比如说NSURL。这是我目前在我的ViewController中所做的:在viewDidLoad中:[myTableViewregisterClass:[CustomCellclass]forCellReuseIdentifier:@"CustomItem"]在tableView:cellForRowAtIndexPath:中staticNSString*myIdentifier=@"CustomItem"CustomCell*cell=[tableViewdequeueRe

ios - 如何将图像添加到 UITableViewCell 删除按钮

我制作了一个可编辑的UITableView,现在我想向删除按钮添加一个图像。到目前为止,我的代码是这样的:代码-(NSArray*)tableView:(UITableView*)tableVieweditActionsForRowAtIndexPath:(NSIndexPath*)indexPath{UITableViewRowAction*button=[UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"×"handler:^(UITableViewRowAction*act

ios - 如何在 uitableviewcell 中快速获得一个圆形的 UIbutton?

classCustomTableViewCell:UITableViewCell{letnameLbl:UILabel=UILabel()letprofileBtn:UIButton=UIButton()letaboutLbl:UILabel=UILabel()overrideinit(style:UITableViewCellStyle,reuseIdentifier:String?){super.init(style:style,reuseIdentifier:reuseIdentifier)contentView.addSubview(profileBtn)contentView

iphone - 使用 CGContextDrawLinearGradient 时如何优化 UITableViewCell 渲染

我有一个UITableView,我试图在其中获得最佳的滚动性能。单元格不包含任何subview,所有都在drawRect方法中完成。每个单元格的顶部有一条白线,底部有一条灰线,顶部和底部之间有一个线性渐变。在此背景之上是一些文本和图像。我可以通过使用工具看到,滚动时运行时间的主要部分(>50%)来自线性渐变的绘制。实际上,几乎所有这些都来自对CGContextDrawLinearGradient的调用。有什么好的优化方法吗?我在想,要么以某种方式缓存线性渐变,要么以另一种方式绘制它...也许绘制一个像素宽然后拉伸(stretch)它?这是我的一些代码:-(void)drawRect:(