Cannot change custom UICollectionViewCell in Storyboard - ios

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.

Related

Height of the collection view is getting calculated wrongly while using tabbar controller in iOS 10

I have created a tab-bar controller in which a sample view controller is present with a container view. The container is embedded with referencedStoryBoard.
The reference storyboard contains a view controller within which collectionView controller is embedded.
When my app runs the collectionView cell height is calculated wrongly. The collection view cell is getting hidden on the top.
Note:
1)Collection view scroll direction is horizontal. On vertical side its working good
2) When I am not using the tabBar the collectionView cell height is getting calculated correctly.
You can find the sample project in this link: https://drive.google.com/open?id=1GbKC_ZhqQAlcLnD24YgxQTZt2toVprwF
The issue is working good in iOS11.
Problem (In my opinion):
At start-up SampleCollectionViewController is created with a normal size (maybe fullscreen size). At this time, collectionView is created and reload. Size of collectionViewCell is calculated base on size of SampleCollectionViewController.
But after that, SampleCollectionViewController is embedded in another controller with a smaller size. Size of SampleCollectionViewController change but collectionView isn't reloaded and collectionViewCell keep start-up size.
Now height of collectionViewCell is bigger than size of SampleCollectionViewController on screen. That's why top of the cell is hidden.
Solution: Call invalidateLayout in traitCollectionDidChange: method. It means that when size of SampleCollectionViewController is changed, calculate cell size and update cells with right size.
SampleCollectionViewController.m
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
[self.collectionView.collectionViewLayout invalidateLayout];
}
Project works normally on my side.
Select your view controller in storyboard. Check if adjust scroll view insets is selected, then unselect it. Thats how i fixed my problem.
When I change the design, I am able to fix that issue for iOS 10. Also working good on iOS 11.
Instead of container view for storyboard reference, I created a segue to call the storyboard reference. As issue is specific to iOS 10 and horizontal collection view, I am gonna continue with earlier design as mentioned in the question.

I want to see all the cells in static table view, which don't appear on the screen in the storyboard

I'm currently studying iOS programming in Swift. In creating a static table view, changing the Rows option more and increasing cells' height while designing them, there happens to be a problem:
The table doesn't scroll vertically in the storyboard. So it doesn't show all the cells I assigned in the Row option. I have more cells to work on. How can I handle this?
You can see by following way
Select the controller in the story board
Go to size inspector and make it freeform , then you can increase the height of main view and can see the full content.

Width and height not adjusting with Xcode Auto Layout

I have created an interface for my app in Storyboard under the Any x Any layout setup, when I run my app the layout is still sized for the square Any x Any and not the phone screen. I want the app to adjust to all sizes and not use a set layout for set screen sizes. How can I do this?
Here are pictures to show my design, and the outcome of running the app.
Storyboard View
Simulator View
The table view is also cut off here
If your ViewController is subclass of UIViewController then add leading, trailing ,top and bottom constraints to UITableView, and contains to your custom navigation bar. or If its subclass of UITableViewController. No need to add any constraints. Just embed your TableViewController into NavigationController.
Hope this will help you
what exactly are you trying to achieve? Your tableview to be entirely on the screen, so not scrollable?
If so, then you should override the layout of your tableview and its corresponding cells. As those cells (and the number of them) define the height of your tableview.
From what I can see it appears that you have manually added a UINavigationBar. I personally find it much easier to embed your view controller into a navigation controller. This will provide you with a navigation bar that will automatically resize depending on the hardware, or size class, of the device. To embed it go to: Editor -> Embed in -> Navigation Controller.
Your TableView seems to be fully in the screen as well? If you have layout issues with your cells not adjusting then I will be more than happy to help you once you clarify what is not quite right.
Hope this helps.
Yep. Been there, done that. Just because something is centered in the Any x Any view in interface builder does not mean it will also be centered e.g. in an iPhone simulator. You always need to make your layout choices explicit with constraints, i.e. in the this case add a "center horizontally in superview" constraint or align the right and left edge with the superview (I really would need to know more about your view controller in interface builder to tell you exactly).
Are you familiar with constraints or should I add some more detail on how to solve this?

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

TableView height change in Swift

I'm trying to find a way of making the height of a UITableView change depending on how many rows are in the table being displayed.
I've gone through the site for previous questions but none really come to any conclusion.
Language being used is Swift on iOS 8.
Thanks,
Anthony
Use tableFooterView to pin content to the bottom of a UITableView
EDIT:
The tableFooterView (and tableHederView) can be modified directly in Interface Builder by dragging a view below (or above) the prototype cell(s) in your table view.
I wanted to do this within the IB. The way around it was to drag a new view underneath the prototype cell that was already showing in the IB. Then I could change the size to suit my footer content and then just add the footer parts of the layout to that new view within the Table View.

Resources