Static UITableviewCells glitch when UIElements are added - ios

I added a UITableViewController and set the type to static. Everything works when there are no UIElements added to the Cells but when one is added, it completely glitches. I deleted all of the delegate methods in the class but the tableview still is messed up. Any ideas?

Ensure that you've set Custom Row height property.
Select cell
Open Size inspector
Set Row Height to 44 (or any other needed size)

Related

Cannot change custom UICollectionViewCell in Storyboard

I have a UICollectionView with custom UICollectionViewCells. I used Interface Builder (via XCode 8) to size the collection view and cells when first making it.
Now, I'm trying to adjust the size of the cells and I'm unable to do so in Interface Builder (using XCode 9). I cannot adjust the width or height of the cells on either the collection view itself or on the custom cell. The up/down arrows don't do anything and neither does typing in a value. It just stays set at 145.
I saw some answers about not being able to do this with a UICollectionViewController via Interface Builder, only a UICollectionView, but it is a collection view and not UICollectionViewController.
I'm sure there's some new setting/config in XCode 9 that I'm missing, but I can't figure out why I can't adjust the custom value.
I ran into the same problem.
Turned out that the item size was defined by the contained flow layout. So editing the item size in the flow layout, and the parent collection view had its item size changed accordingly.
I tried Jonny's answer, but I use a custom FlowLayout and couldn't edit it's cell size either. I had to manually edit the size of the collection view, the cell and the layout in the storyboard source code (right-click on the storyboard in project view and select "open as / source code").
Now the size is correct but still not editable from the UI ¯_(ツ)_/¯
Same problem, width would not change. But I changed the height to something different and it then let me edit the width.
Xcode 12.3. I had the same issue and what fixed it for me was changing the collection view scroll direction from vertical to horizontal to make the change, then obviously reverting back to vertical (my intended direction) once I was done editing the values.

UITableview with Autolayout and NSFetchedResults controller cell layout bug on insert

I seem to be having a very strange problem with my UITableview cells and autolayout. So my tableview is set up as follows:
I have a UITableView within a UIViewController that I created via Interface builder using Autolayout
My tableview is using UITableViewAutomaticDimension so that the cells can resize based on the text within them.
Each cell has 2 subviews within it. A front view and a back view. The back view contains the buttons for my slide-able cells
I am using NSFetchedResults controller to update the tableview
The problem occurs when I tap on a cell and am taken to the next view. Then I create a core data item within that view and save so that it is inserted into my tableview (now behind the current view controller).
What happens is that the newly inserted cell seems to lose all autolayout constraints and all view elements are on top of each other in the top left of the cell. It also looks like they are not even contained within the front view for the cell (or the front view has a width and height of 0).
Example:
It gets even stranger. If I refresh the tableview by pulling down and the cells are reloaded it corrects itself. However, if I refresh the tableview again then the problem appears again but on a different cell. This bug does not happen consistantly which is rather frustrating.
Any help would be appreciated as I only have a few remaining hairs on my head to pull out at this stage.
Thanks in advance!
So I found out what the issue was. The issue was that I was using size classes in Interface builder but I was only using the iPhone Portrait size class and did all my work in there instead of the "any" size class. Disabling size classes and setting the project to iPhone only fixed all these problems.
Weird I know

Text not appearing in tableview controller

I have a tableview controller as my initial view. I added some text into it and it's not appearing. First i added some labels, and none of them was appearing, i thought maybe it was a constraint problem. So i added constraints and still didn't work. Then I made the cells basic rather then custom. In basic, it gives you text for you. And still the text isn't appearing. How can i fix this?
Note: This is a new project, I have tested this on a real device and have the same issue.
The table is created with the default prototypes of cells (Content field is Dynamics Prototypes) that need to create and add from the code. If you want to make a static cell, you need to do this in storyboard:
Select TableView
Set Content field in Attributes Inspector to Static Cells
Add your labels to Static cells

Static Cell properties having no effect when set in storyboard IB

I have dragged a table view into my view, set it to static, set the number of cells and sections, changed colours, added controls and modified the size. When I run it though, the changes do not show up. Am I missing something here?

Static table view cell's height in xib not being applied

I have created a static table cell in a .xib, however when it is displayed the cell height set in the xib is not being applied, instead the cell is being displayed with what looks like the default height for cells.
I have set things up as:
1) The table view controller derives from UITableViewController
2) The TVC is not contained within a xib and is created in code in the app delegate and added to a tab bar controller.
3) The TVC is created using initWithNibName:bundle: with the nib name supplied as the name of the xib containing the table view and the static table cell.
4) The TVC has an IBOutlet iVar of type UITableViewCell*
5) cellForRowAtIndexPath returns this iVar.
6) numberOfRowsInSection returns 1, numberOfSectionsInTableView returns 1;
7) The xib contains a table view, which is connected to the File's Owner's view. The File's Owner is set to my custom table view controller class.
8) The UITableViewCell in the xib is connected to the outlet of type UITableViewCell in the File's Owner.
9) THe Table view style in the xib is set to grouped.
10) The size of the Table View Cell shown in the size inspector is N, and this is where the problem is. If I change N manually or by resizing the cell visual representation then this size is not applied when the table is drawn. I have also tried setting the view Frame Rectangle height in the size inspector to match.
It doesn't matter what value N is, big or small.
11) The cell's height is not being set anywhere in the TVC, if I do set it using self.tableView.rowHeight then its height does change. But I do not want to set it explicitly like this, I want the height size in the xib to be picked up.
This has been driving me nuts for a few days, and reading several tutorials on table views (including Apple's table view programming guide, especially the section on static cells, whose instructions I followed in the first place to set everything up) has not given me any clues where the problem lies.
TIA
Implement heightForRowAtIndexPath and return the height of the UITableViewCell linked to in your IBOutlet.
Do you have - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath defined in your UITableView delegate?
You may want something like:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 30;
}
Try this post if you're still having trouble try this post: Setting custom UITableViewCells height
I had the same problem and everyone here and on other threads suggests writing code to fix the problem, which seemed wrong. What's the point of using IB if you have to write code to get the properties right?
The answer turns out to be very simple but took a bit to track down. In IB there are two places that row height can be set (just like there are two places to set it in code). One is on the table, the other is on the cell.
The place I was (incorrectly) setting it was the tableViewCell's "Row Height" property in the Property Inspector. Changing this value had no effect on row height at runtime.
Then I found and set the "Row Height" property of the TableView (one step up the object hierarchy) and viola, the row height is correct at runtime. Once this was working I turned off the override of Row Height on the TableViewCell (uncheck "Custom" on the Row Height property). I was afraid this might be evaluated on each cell, which would kill performance since all my cells are the same height.

Resources