FZAcordion TableView Text goes Beyond the bounds - ios

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.

Related

self sizing tableview cell is not estimating heigh as expected

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.

Swift - Static UITableView growing with UITextView

I have a static UITableView and one of my rows have a UITextView inside of it with autolayout pinned top to bottom left to right as 0.
I want the UITableView's contentView to resize depending on the content of the UITextView however I'm having difficulties working around this. I've scrapped the code I originally used as it wasn't working at all. Any solutions?
If the content of the textview is static.
Set SrollingEnabled to false in UITextView.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 200
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
If the content of the textview is dynamic.
Do the same thing as static and set the delegate for UITextView to self. Then in UITextview delegate.
func textViewDidChange(_ textView: UITextView) {
tableView.beginUpdates()
tableView.endUpdates()
}
This will definitely work.

Swift UIView Border adjusts after UITableView scrolling

I have a problem with my UITableView sections (and their height, I guess).
Within a section header, I have a view (named cornerRadiusView) within which there are few labels. These labels have dynamic content (fetched from a REST service). So whenever a UILabel height is increased, I am increasing the height of the cornerRadiusView to properly accommodate the content.
The problem is, all this works as expected only when I scroll my tableView. Till then, the heights are improper.
Here I am posting GIF to show what's going on.
I can give more details and code as needed. Could someone please look at where there is a problem?
You can use below functions
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
And reload table view in below method
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
tableview.reloadData()
}
And if you are maintaining dynamic height then manage those height in cell
override func layoutSubviews()
{
}

Updating height of async loaded images

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:

TableViewCell Auto height issue

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.

Resources