iOS 8.3 - UITableView cell height bug - uitableview

On previous iOS versions cell height was working perfectly now it doesn't get the explicit height I give at the uitableview delegate. By the time, I updated to 8.3 rendering is so bad. It goes smaller and towards right.
Am implementing a custom cell using a xib file and Swift.
I saw some 1-2 similar posts but I couldn't comment below due to reputation. So I have already try to add constraints to awakeNib and updateContraints methods but when I try to add a constraint it crashes.
[Edit]
While trying to add constraint, I get this error message:
-> 'Impossible to set up layout with view hierarchy unprepared for constraint.'
And when tried to setup a visual formatConstraint V:|[contentView]|
-> Parse error and View doesn't have superview
Thanks.

I have found out what was going wrong.
Before the iOS 8.3 update the table view should somehow auto calculating the height of the custom cell and everything was working properly.
My mistake was that i believed that i had correctly connect the table view's data source and delegate at the controller. I had only connected the datasource. As a result as soon as i connected the delegate everything was working properly.
myTableView.datasource = self
myTableView.delegate = self <- this was missing

Related

Autolayout is ignored in custom TableViewCell

I'm trying to constrain some objects in my tableview cell so that they will be formatted correctly and won't clip on different devices. But, whenever I add a constraint to an object in there, it throws the object off screen to the top left. In the screenshot I attached I showed it with the green bar on the left but the same is true when I do it to the other labels and text fields.
Any ideas as to what I'm doing wrong?
I have a near identical table view that gets its data from another source and have them constrained the same way, but that tableview cell is formatted correctly when I build it.
I am seeing things online about Tableview cell subclasses. Is there something else I am supposed to be implementing in order to get these to stay? I'm not sure why they are working on one of my tableviews but not the other.
I am having the same issue that is being seen here Autolayout is ignored in Custom UITableViewCell but her answer is confusing me and I can't figure out how to reproduce it
This is what it looks like when the app is built:
Figured it out. For anyone else who may have this problem in the future. You need to click on the content view in the Storyboard and go to the indemnity inspector. Then from there make sure the Class is set to the default of UIView and not the custom class of the TableView Cell.

Xcode 8 autolayout constraints don't work in custom tableViewCell

I have an app that uses custom tableviewcells. When I use autolayout for subviews (e.g. UIImageView, UILabels) on runtime I dont see any of the subview even though the constraint lines are blue. Everything was fine before i updated to Xcode8.
Constraints work fine on in other views.
EDIT: Here is the screenshot. Imageview is not displayed at all, even though it has placeholder image by default and there are images in source to replace the placeholder.
EDIT: same code without constraints.
I had a similar problem when using custom table view cells and auto layout. Somehow when I called [self.tableView registerClass:[CustomCell class] forCellReuseIdentifier:#"cell"] the cell wouldn't show. However once I removed this line from the viewDidLoad: everything worked properly
It's not certain that you have things layed out this way but this is what worked for me. Also, if you use anything like an autoresizingmask, turn that off for your constraints to work. You could also try selecting the Content View of the cell in interface builder and deselect "Autoresizes Subviews".

Auto-layout features not working in a table view cell in xcode?

I am making a simple app since I'm quite new to xCode. I have a table view which holds cells. I've added constraints that I was hoping would dynamically change the width of the cell depending on the device (iphone vs iPad). However, it doesn't seem to be working.
I believe I've set all the necessary constraints, but I guess I must be missing some.
Here is an image of what I'm working with:
And this is the problem, when I change the size of the device I'm working on, the labels in the cell don't resize themselves.
Here are the constraints I'm currently using:
Any help would be appreciated, thanks.
Most probably you haven't updated the frames after changing the size of the view controller

Xcode messed up constraints and auto layout after reloading project

I have a static table (UITableViewController) with few cells , its a data entry form basically, when i created this and put all the constraints all was good until i reloaded the project , now all the components are outside of view and entire layout is messed up along with constraints. This has happened twice and i have no idea why this is happening
I deleted entire project and pulled it from repository , but still its same
important thing is this runs fine inside app, shows the correct screen , so looks like this is some Xcode rendering specific issue,also this it not happening with some other screens in project, I have tried deleting tableviewcontroller and adding it thrice but same result.
This TableViewController is linked to a UIViewController which has collectionview upon taping one of the collectionview cell this view gets laucnhed and hence linked though a show segue.
****** edit ***********
Figured it out , this happens especially when i add height and width constraints to the label and textfield
ok here is how i solved the issue ,
I found out that if i add height constraints on controls inside a TableViewCell then it would mess up the design, thus not adding height constraints and instead managing with top and bottom spacing helped. Still not sure why this is happening to only certain TableViewController and not all.

UITableView in storyboard not updating content size on rotation

I'm working on project targeted for iOS 6 that leverages storyboards and auto layout. In the storyboard there are many places where a UITableView is added as a subview to a view controllers view. This table view uses prototype cells from the storyboard.
The issue we're running into is that if the view controller is initially loaded in landscape orientation and the device is then rotated to portrait, the table view begins to scroll both vertically and horizontally. The table views cells are drawn with the correct dimensions but there is additional white space to the right.
It appears that while the frame and bounds of the table view are being updated to the correct size on rotation, the table views content size is not. Regardless of any update rotation change the content size remains the same dimensions.
The issue doesn't present itself if programatic table view cells are used.
A few garish work arounds I've found, 1.) calling reloadData or reloadRowsAtIndexPaths:withRowAnimation: 2.) manually setting the property contentSize.
Both of these seem less than ideal.
I've added this
link to a dead simple sample project which demonstrates this issue. The only changes made are to the storyboard and the main view controllers implementation.
Before rotation
After rotation
I'm having the same issue - can't seems to find any documented answer related to this. I ended up manually modifying the UITableView contentSize like you mentioned in:
- (void) viewWillLayoutSubviews
{
self.tableView.contentSize = CGSizeMake(self.tableView.frame.size.height, self.tableView.contentSize.height);
}
I ran into this issue today and filed a bug report with Apple.
Appears that if you are using a custom cell with a UI element AND autoLayout, the UIScrollView content size is having problems.
If you remove all UI elements, OR turn off autoLayout, OR use a factory cell (basic, etc), all works fine.
Same issue I have rectified in my project.
I guess this is a bug in Storyboard.
Then I have solved it by manual coding in willAutorotate method by setting
tableview.contentsize = CGSizeMake(tableview.width, tableview.contentsize.height);
Hope this will work for you as well.
If you find any apple documentation regarding the same then please update me as well. Till then you can use the same solution.
Appears that if you are using a custom cell with a UI element AND autoLayout, the UIScrollView content size is having problems.
I had to turn off AutoLayout for my custom UITableViewCells to be able to scroll to the bottom on updating the data and then [self.tableView reloadData].
With AutoLayout turned on, the tableView.contentSize was being updated, but I still wasn't able to scroll to the bottom unless I rotated the device.
I found the following to work for me:
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
dispatch_async(dispatch_get_main_queue(), ^{
self.tableView.contentSize = CGSizeMake(self.tableView.frame.size.width, self.tableView.contentSize.height);
});
}
Notice the async dispatch: if that line would be executed synchronously then the contentSize change would trigger another layout pass before the current one would have completed. This triggers an exception:
Auto Layout still required after sending -viewDidLayoutSubviews to the
view controller.
Usage of Constraints helped me. Since you are using Storyboards, it is really easy to set Constraint values for all edges, so UITableView will always fill the whole ViewController (of course if UITableView fills whole ViewController) regardless of device orientation.
I had the same problem.
I found this link. When I tried to implement this I did not find the Auto-sizing attributes for my view then I clicked on Master View Controller and then clicked on the File Inspector and uncheck Use Autolayout and then go to Attributes inspector auto-resizing should be there then you can change the attributes how you want it.
I am sure you must have managed to figure this out.

Resources