Open ErAshu opened 6 years ago
How do you layout TagView in a tableview cell?
See the attached Screenshot.
What's the code in tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
method?
I also get this issue. In my case, when I change height of tableview cell (static cell), the tagview doesn't.
UITableViewAutomaticDimension
tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
I am having the same issue. kindly help me. why this section is closed I read here but I dint find the solution for it. revert asap.
I also get this issue. In my case, when I change the height of the TableView cell (static cell), the tag view doesn't.
I got the same issue. Would you able to resolve it?
Any update on this?
This is what the issue looks like for me: The cell is set to UITableView.automaticDimension but the view doesn't expand enough. The last 3 rows are cut off from any taps.
Same problem. My UITableViewCell doesn't expand enough.
What's the code in
tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
method?
Any solution??!!
add notificaiton to reload superview frame. it is not best way, but this way can deal it.
Same here. Conflict happens when there are other views in the same cell and have multiple rows of tags.
I also have the same problem ,I am thinking that the TagListView content layout is finished before table view reload completed so that the cell which contains the TaglistView did not updated it's content layout. what I do is just reloading the tableview layout after reloadData() :
tableView.reloadData()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {[weak self] in
self?.tableView.beginUpdates()
self?.tableView.endUpdates()
}
and the problem solved: may this help
I also have the same problem ,I am thinking that the TagListView content layout is finished before table view reload completed so that the cell which contains the TaglistView did not updated it's content layout. what I do is just reloading the tableview layout after reloadData() :
tableView.reloadData() DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {[weak self] in self?.tableView.beginUpdates() self?.tableView.endUpdates() }
and the problem solved: may this help
Awesome. It worked for me thanks alot
Also for me the solution is to set margins and paddings programmatically, not from interface builder:
tagListView.paddingX = 7
tagListView.paddingY = 7
tagListView.marginX = 7
tagListView.marginY = 7
by using tagListView.subviews.count we can get the height.
height = (tagListView.subviews.count * 32) + topMargin + bottomMargin
this will fix height issue
I had similar issue and resolve it thanks to reloadData
call inside viewDidAppear
one.
The solution was found here: https://github.com/zekunyan/TTGTagCollectionView#fix
hey guys, i have the proplem, i'm try reload the tableview layout,but not working,please help me
I'm using TagListView in a table view with static cells. I calculate my TagListView's height like this:
import Foundation
import TagListView
extension TagListView {
var height: CGFloat {
// row count. If tagView doesn't have an item it will be 0
let count = CGFloat(self.subviews.count)
// subview (aka row) height. If no row exists 'first' item will be nil, so we set 0.
let height = self.subviews.first?.frame.height ?? 0
// margin
let margin = self.marginY
// calculate total height.
// subview count times height + subview count - 1 times margin
// if count is 0 we don't want to make the view minus margin height
return CGFloat((count * height) + (count == 0 ? count : count - 1)) * margin)
}
}
This will give you the exact height of the view.
Now you can set the cell height:
if you are using static cells like me:
@IBOutlet weak var myCell: UITableViewCell
func someFunct() {
// do stuff
myCell.frame.size.height = tagList.height
}
if you are using dynamic cells :
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == theRowYouWant {
return tagList.height
}
return aDefaultValOrSomethingElseIDontCare
}
// then use reload cells / reload data or smth
I'm using TagListView in a table view with static cells. I calculate my TagListView's height like this:
import Foundation import TagListView extension TagListView { var height: CGFloat { // row count. If tagView doesn't have an item it will be 0 let count = CGFloat(self.subviews.count) // subview (aka row) height. If no row exists 'first' item will be nil, so we set 0. let height = self.subviews.first?.frame.height ?? 0 // margin let margin = self.marginY // calculate total height. // subview count times height + subview count - 1 times margin // if count is 0 we don't want to make the view minus margin height return CGFloat((count * height) + (count == 0 ? count : count - 1)) * margin) } }
This will give you the exact height of the view.
Now you can set the cell height:
if you are using static cells like me:
@IBOutlet weak var myCell: UITableViewCell func someFunct() { // do stuff myCell.frame.size.height = tagList.height }
if you are using dynamic cells :
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if indexPath.row == theRowYouWant { return tagList.height } return aDefaultValOrSomethingElseIDontCare } // then use reload cells / reload data or smth
thanks , let me try
tableView.reloadData() DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {[weak self] in self?.tableView.beginUpdates() self?.tableView.endUpdates() }
Works perfectly
TagView height is not working perfect with tableView Cell.
Its clipping from bottom.