【发布时间】:2017-11-15 06:01:30
【问题描述】:
如何使用自定义按钮选择 tableview 行。我有另一个按钮,称为选择所有它在表格视图之外我的问题是在点击表格视图按钮外部时如何在表格视图行内选择和取消选择?同时我可以在表格视图中选择单行吗?如何在swift 3中做到这一点?这是我在 cellforrow 方法中的代码
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let identifier = "Custom"
var cell: TStudentAttendanceCell! = tableView.dequeueReusableCell(withIdentifier: identifier) as? TStudentAttendanceCell
if cell == nil {
tableView.register(UINib(nibName: "TStudentAttendanceCell", bundle: nil), forCellReuseIdentifier: identifier)
cell = tableView.dequeueReusableCell(withIdentifier: identifier) as? TStudentAttendanceCell
}
print("studentAttendanvceArray--",studentAttendanceArray.object(at: indexPath.row) )
var localDic :NSDictionary!
localDic = studentAttendanceArray.object(at: indexPath.row) as! NSDictionary
Common.sharedInstance.StopActivity()
cell.profile_img.image = self.image
cell.name_lbl.text = localDic["student_name"] as? String
cell.selectionStyle = UITableViewCellSelectionStyle.none
cell.contentView.backgroundColor = UIColor.clear
let whiteRoundedView : UIView = UIView(frame: CGRect(x: 10, y: 8, width: self.view.frame.size.width - 20, height: 90))
whiteRoundedView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.9])
whiteRoundedView.layer.masksToBounds = false
whiteRoundedView.layer.cornerRadius = 2.0
whiteRoundedView.layer.shadowOffset = CGSize(width: -1, height: 1)
whiteRoundedView.layer.shadowOpacity = 0.2
cell.contentView.addSubview(whiteRoundedView)
cell.contentView.sendSubview(toBack: whiteRoundedView)
return cell
}
【问题讨论】:
-
你的问题不清楚提供相关代码
-
我已经看过该代码,但这里我的所有按钮都在 tableview 之外。
-
@kishan 我在 cellforrow 方法中没有看到任何按钮。你有吗?
-
@rajesh 我没有写任何东西我没有得到任何东西怎么做那为什么。
标签: ios swift uitableview