azizuysal / aupickercell Goto Github PK
View Code? Open in Web Editor NEWEmbedded picker view for table cells.
License: MIT License
Embedded picker view for table cells.
License: MIT License
How do I collapse a cell when a new one is selected?
I've implemented it like the README says but it's giving me some assertion issues. I don't know if this is normal or not, I'm fairly new to cocoapods. When I would comment out the heightForRowAt
it would not give me any assertion info. Is this something I need to fix or just keep it like this? Furthermore the pickers work as it should with no issues.
Full info:
[Assert] Attempted to call -cellForRowAtIndexPath: on the table view while it was in the process of updating its visible cells, which is not allowed. Make a symbolic breakpoint at UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate to catch this in the debugger and see what caused this to occur. Perhaps you are trying to ask the table view for a cell from inside a table view callback about a specific row? Table view: <UITableView: 0x14e818800; frame = (0 0; 375 812); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x280f51a40>; layer = <CALayer: 0x280103840>; contentOffset: {0, -88}; contentSize: {375, 325.33333333333337}; adjustedContentInset: {88, 0, 34, 0}; dataSource: <SkiMapMarker.AddTripsTVC: 0x14fe066b0>>
Code:
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if let cell = tableView.cellForRow(at: indexPath) as? AUPickerCell {
return cell.height
}else if indexPath.section == 0 && indexPath.row == 1 {
return 200
}else{
return super.tableView(tableView, heightForRowAt: indexPath)
}
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
if indexPath.row == 0{
let cell = tableView.dequeueReusableCell(withIdentifier: "GebiedNaam", for: indexPath) as! GebiedNaam
cell.gebiedNaamLabel.text = gebiedNaam
return cell
}else{
let cell = tableView.dequeueReusableCell(withIdentifier: "GebiedKaart", for: indexPath) as! GebiedKaart
cell.imageViewCell.image = kaartAfbeelding
return cell
}
}else{
if indexPath.row == 0{
let cell = AUPickerCell(type: .date, reuseIdentifier: "DatumStartPicker")
cell.datePickerMode = .date
cell.leftLabel.text = "Start:"
cell.dateStyle = .medium
cell.timeStyle = .none
cell.delegate = self
return cell
}else {
let cell = AUPickerCell(type: .date, reuseIdentifier: "DatumEindePicker")
cell.datePickerMode = .date
cell.dateStyle = .medium
cell.timeStyle = .none
cell.leftLabel.text = "Einde:"
cell.delegate = self
return cell
}
}
}
Unless the Picker is closed, the data contained in the right labels of the cells below are deleted.
Can you help me to resolve?
I changed this to the AUPickerCell.swift class to increase the height of the list when opening the picker:
public func selectedInTableView(_ tableView: UITableView) {
let unexpandedHeightList = CGFloat(Double(tableView.numberOfRows(inSection: 0)) * 29.5)
let expandedHeightList = unexpandedHeightList + picker.bounds.height
let heightList = !self.expanded ? expandedHeightList : unexpandedHeightList
print(heightList)
let expandedFrame = CGRect(x: tableView.frame.origin.x,
y: tableView.frame.origin.y,
width: tableView.bounds.width,
height: heightList)
print(expandedFrame.height)
if !expanded {
rightLabelTextColor = rightLabel.textColor
}
expanded = !expanded
UIView.transition(with: rightLabel, duration: 0.15, options: .transitionCrossDissolve , animations: { [unowned self] in
tableView.frame = expandedFrame
self.rightLabel.textColor = self.expanded ? self.tintColor : self.rightLabelTextColor
})
tableView.beginUpdates()
tableView.endUpdates()
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.