How to give constraints to a tableview when tableview cell is on xib. And table view is on storyboard - ios

I have a table view on storyboard i.e. FirstStory.Storyboard. And for this tableview I have created a table view cell on xib file where I give size to its width as per my current storyboard width. But when I launch my app it runs fine on the landscape position. But when I rotate it in the portrait mode. Width is unable to show the all item which I placed in tableviewcell.xib. How we mutually combine these two item in storyboard (table view on storyboard while cell on xib). Which follow a single constraints with above condition.

UITableViewCell's contentView property is always the size of the cell. So you have to setup the constraints of your UI components in the xib file with the Cell's contentView properly. The issue you are facing must be because you did not setup these constraints properly.
To see which views or constraints have been placed wrong, use the XCode's 'Debug View Hierarcy' feature.
Launch it from here
Run your app, navigate to your tableView, then press the above button to launch the view debugger. It provides very good insight into your constraints and where the issue may lie

Related

Issue with Autolayout and StackView while using ScrollView

I a trying to create a UIScrollView that fits exactly the contents of its subviews. I do this with a StackView and the scroll view's height is determined by how much content there is in the stack view. Within the stack views, there are views that contain an UIImageView and a UITextView
The UIScrollView starts below the title view, however every time I want to add another view (which it should scroll when the content is bigger than the actual frame) there is an issue with the scroll view's Y position. This works perfectly if I only add UILabels and UITextFields, using the same procedure
How can I do it so I can programmatically add views on the stack view that includes an UIImageView and a UITextView, just as the View Controller with labels and textfields does.
You can download my app project at the following url
https://github.com/francisc112/DescriptionWithImageApp.git
Instead of a scroll view why don't you use a table view and create a custom cell with the stackview and its contents inside the cell and you can dequeue the same cell for adding multiple information.
I was not able to open your project
So I Tried opening your StoryBoard and Re-Viewing your constraints Applied , here is what I have Done Please check in following Link
Link - https://drive.google.com/file/d/1D-dzKsSqpx7dWsI5fYRdAfCMY_vENoIR/view?usp=sharing
View Hierarchy
Note - For such output I will prefer using a TableView instead of StackView as Same output can easily be achieved using TableView

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.

IOS/Autolayout: Set constraints for tableview

I am trying to set the constraints for a tableview. However, I cannot CTRL-Drag from the tableview to the view controller and when I select the tableview, the autlayout controls are inactive. Can anyone suggest the proper way to apply auto layout so that a tableview acts correctly for all screen sizes?
storyboard
Pin in autolayout

Storyboard placement incorrect

I have a UIScrollView placed inside a UIScrollView container. While the placement of the sub-view appears correct in the Storyboard, it is off when I run the app (both on the simulator and an external device). In order for the view to appear properly, I have to place it oddly in the storyboard as follows:
Layout appears correct in storyboard but incorrect in app:
Layout appears incorrect in storyboard but correct in app:
To enable vertical scrolling in the parent UIScrollView, I turned off Auto Layout, and for the ViewController, I set size to 'freeform"
Does anyone have advice for how to layout my views to appear correct both in the storyboard and in the app?

Why UITableView on the device smaller than in IB

When I create my UI in IB I can't do it right because UITableView height not equals its height on the device.
I don't understand why?
Example:
http://img35.imageshack.us/i/20110401111017.jpg
This is happening because the view is being resized when it is pushed on the navigation stack. You can fix this several ways. The best thing to do it setup your nib so it matches the displayed size. You can also remove te autoresize flags from the UITableView. Finally you could programmatically resize the view inside of the view controller's viewWillShow:(BOOL)animated.

Resources