I wanna get like this:
I am using a custom UITableViewCell where I download images asynchronously with Alamofire from within the cell.
The images appear after the cell was loaded from within the UITableviewController.
Some images do not exist. So the cell should be collapsed and show only text if there is no image present.
How can I achieve to resize the cell when the image is present?
(All images should appear in the same height and full width.
What I already tried is something like this in my TableViewController:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 80
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
But the result is pretty ugly:
Related
I have a chat view where I'm using tableview to display different custom cells for incoming and outgoing messages and the app was working fine till ios 13,
But as soon as I updated the phone OS to ios 14 its giving me issue
the issue is seems to be likely in dequeueReusableCell function, bigger cells taking height if smaller cells and smaller taking height of bigger cell instead of their own cell content
I have used the table height like this
IN VIEW DIDLOAD FUNCTION
self.chatTableView.estimatedRowHeight = 44
self.chatTableView.rowHeight = UITableView.automaticDimension
internal func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
Also tried to use
cell.setNeedsLayout()
cell.layoutIfNeeded()
at differenct places like when the heightForRowAt, cellForRowAtIndexPAth and willdisplayCellForRowAtIndexPAth get called but getting the same issue
I have a tableView cell with constrains that works nice in Xcode 9, and iOS 10, after upgrate to iOS 12 and Xcode 10 the self sizing stop working, tableView was unable to determinate the cell size.
The cell designing is this with all constraints:
So setting by code the automatic dimension
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 196
}
The result is that I have to use the height for row with a number instead of automaticDimension to see the cell in tableView. So, I'm missing a constrain here or what.
I've got problem is how can I increase UITableViewCell based on UIImage inside content.
Image from URL will be downloaded and display inside UIImageView with AlamofireImage.
I've added as follow:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
and configure right constraint like that
Please let me know where I'm missed.
I am writing an iOS app.
User types in movie search keywords and it fetches data from omdbapi.com and displays movies in tableview.
Issue is that that table view cell isn't getting displayed correctly.
Project URL:
project on onedrive
I tried using every autolayout method but, its not working.
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension;
}
You need to set estimate method for table height too. so place these method for height calculation and also check your cell constraint.
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Hope this will help you.
I am new to IOS and anyhow i have implemented the FZAccordion from HERE. Now my problem is when i have a long text in header section and cells it goes beyond the bounds.So how can i get rid of this problem so that no matter how long is the text it always fits in the screen.
Thank you.
You can use
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
override func tableView(_ tableView: UITableView,estimatedHeightForRowAtindexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension}
This will automatically resizes your text in your cells.