当我滑动UITableView单元格时,会调用以下代码:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
//Problem code
let delBut = UITableViewRowAction(style: UITableViewRowActionStyle(), title: delete_InLocal) { action, index in
//Setup
Run Code Online (Sandbox Code Playgroud)
现在我已经开始迁移到Swift 3,我在UITableViewRowActionStyle()上收到一条错误消息:
调用中缺少参数'rawValue'的参数
任何人都知道Swift 3在这种情况下的语法是什么?
我试图在选择表视图单元格时删除突出显示,但希望保留显示的复选标记。
当我在 cellForRowAtIndexPath 中尝试此操作时:
cell.backgroundView = UIView()
cell.backgroundView?.backgroundColor = UIColor.clearColor()
Run Code Online (Sandbox Code Playgroud)
它仅删除复选标记下方的突出显示,而不是整行(请参阅附图)。

当我在 cellForRowAtIndexPath 中尝试此操作时:
cell.selectionStyle = UITableViewCellSelectionStyle.None
Run Code Online (Sandbox Code Playgroud)
它不再显示复选标记。
更新:尝试过这个,与 cell.selectionStyle 做同样的事情,它不再做复选标记
func tableView(tableView: UITableView, shouldHighlightRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return false
}
Run Code Online (Sandbox Code Playgroud)
这样做的好方法是什么?我希望它仍然像复选框一样工作,但只是不希望出现蓝色突出显示。TableView是动态生成的:
checkBoxView = UITableView()
checkBoxView.frame = CGRect(x: qView.bounds.midX, y: qView.bounds.midY, width: qView.bounds.width - 100, height: qView.bounds.height/1.5)
checkBoxView.center = CGPointMake(qView.bounds.midX, qView.bounds.midY)
checkBoxView.delegate = self
checkBoxView.dataSource = self
checkBoxView.tag = 100
checkBoxView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
checkBoxView.setEditing(true, animated: true)
self.qView.addSubview(checkBoxView)
Run Code Online (Sandbox Code Playgroud)
表格视图功能:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return …Run Code Online (Sandbox Code Playgroud) 通过调用更新iOS 11.2的新XCODE 9.2后出现了奇怪的问题
let indexPath = IndexPath(item: 0, section: 1)
self.tableViewHome.reloadRows(at: [indexPath], with: .none)
Run Code Online (Sandbox Code Playgroud)
它导致整个TableView不必要的抖动,事先对这些代码非常好.
适用于iOS 11.2的GIF图像
适用于iOS 11.1的GIF图像
如何阻止这个Jerking,我必须在两个单元格中重新加载tableview中的一个单元格.
任何帮助将不胜感激.
谢谢
我正在使用UIContextualAction滑动来删除功能UITableViewCell.我使用+ (instancetype)contextualActionWithStyle:(UIContextualActionStyle)style title:(nullable NSString *)title handler:(UIContextualActionHandler)handler方法构造UIContextualAction,然后使用setImage:属性将图像设置为它.
但是,当我运行此代码并尝试滑动删除时,只有图像显示在菜单中.标题丢失了.当我注释掉该setImage属性时,会显示标题.为什么会这样?我是否遗漏了实施中的内容,或者这是Apple的错误?
你如何为 中的标题设置自定义字体UIContextualAction?
我试过了,UIAppearance但没有任何运气......
干杯! :)
uitableview ios uitableviewrowaction uiswipeactionsconfiguration uicontextualaction
我想添加编辑操作以在用户滑动表格行时显示。我以前可以使用该tableView(_:editActionsForRowAt:)方法,但现在已弃用。在该tableView(_:commit:forRowAt:)方法中,我不需要执行任何操作。如何为我的单元格添加操作?
实现闪烁动画时,不会在 UITableViewCell 上执行任何操作,它开始闪烁,正常但不可点击或可滑动。我尝试了一些解决方案,但无法修复。代码如下。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell.backgroundColor = UIColor.colorWithHexString(hexStr: "#FDFAEB")
cell.blink()
return cell
}
Run Code Online (Sandbox Code Playgroud)
动画扩展代码:
extension UIView {
func blink() {
self.alpha = 0.5;
UIView.animate(withDuration: 0.7, //Time duration you want,
delay: 0.0,
options: [.curveEaseInOut, .autoreverse, .repeat],
animations: { [weak self] in self?.alpha = 1.0 },
completion: { [weak self] _ in self?.alpha = 0.8 })
}
}
Run Code Online (Sandbox Code Playgroud)
请告诉我,这是什么原因,我该如何解决?
我正在开发一个具有与“ Instagram”中相同的UI的应用程序。我有一个供稿墙,用户可以在其中滚动并查看朋友添加的新图片,类似于instagram。每个UITableViewcell都有一张图片和它自己的节Header视图。我已经通过为每个单元格创建部分来实现这一点。但我担心内存泄漏
这是我的代码
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 45))
headerView.tag = 101
let imageView :UIImageView = UIImageView(frame: UtilityManager.setFrameWithOutHeight(CGRectMake(22, 5 , 30, 30)))
imageView.backgroundColor = UIColor.blueColor()
imageView.tag = 101
imageView.layer.cornerRadius = 15.0
imageView.clipsToBounds = true
imageView.layer.borderWidth = 1
imageView.layer.borderColor = UIColor.grayColor().CGColor
headerView.addSubview(imageView)
var label = UILabel(frame: UtilityManager.setFrameWithOutHeight(CGRectMake(50, 5, 320 - 60 , 35)))
label.textAlignment = NSTextAlignment.Left
label.backgroundColor = UIColor.clearColor()
label.textColor = UIColor(red: 1, green: 0.28, blue: 0.27, alpha: 1)
label.text …Run Code Online (Sandbox Code Playgroud) ios ×9
uitableview ×8
swift ×5
ios11 ×2
animation ×1
memory-leaks ×1
swift3 ×1
uicolor ×1
uiswipeactionsconfiguration ×1
xcode ×1