Why UITableView on the device smaller than in IB - uitableview

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.

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.

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

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

iOS - Main view resizes - additional UIViews do not

In my XCode project, I have a xib file and the main view resizes for the iPhone 5 (as do its subviews).
I have additional UIViews in this Xib (they're not set as subviews of the main view, though) and these ones don't resize even though I have set the auto sizing properties.
Am I doing something wrong or is there a reason that these additional UIViews aren't resizing?
Thanks.
EDIT: I am adding these views as subviews to a parent view in my viewdidload method. Maybe I should do it in viewWILLload?
Seems I've managed to figure it out! You have to set the frame of the UIViews in viewWillAppear to be whatever size you want and then the subviews will resize.
Luckily, in my case, all my tall narrow views that you can see in the screen grab above, are all going to be the height of the screen, so I can set it there and have the subviews position/resize accordingly.

UITableView and Another View inside ScrollView

I have UITableView and UIView(used to show image slideshow) inside UIScrollView. The tableview is dynamic and i want to automatically adjust height of table view to show all the cells(and disable scrolling of tableview) and scrollview should show both slideshow and tableview and could be scrollable, I know how to do this with code but i want to know if is possible to do in Interface builder(without using iOS6 auto layout) using previous(iOS5 and early) autoresize method in the xcode size inspecter tab(see image)
I think this is hard to do only using interface builder.
You can set your objects via interface builder. But for maintaing scrolling conditions you need to do it programmatically. Also for table view height to be dynamic you need to be done programmatically.

iPhone + resize UITableView

I have a view in which I have UITableView (grouped style). In the Interface builder, I am resizing the UITableView so that it looks like a small portion in center of the screen.
But when I run the application, UITableView takes up the whole area of screen and does not look like the small portion in center of screen (which I had set in Interface builder).
I tried to resize the tableView programmatically in the viewDidLoad method as tableView.frame = CGRectMake (0.0,0.0,100.0,100.0), but still the tableView occupies the whole area of screen.
Please help.
Regards,
Pratik
Sounds like your table view's got autoresized. Try to fiddle with the autoresizing settings.
If your table view is the main view then it will automatically fill the whole view controller's space regardless of the autoresizing settings. In that case, make an empty UIView as the root view and put the UITableView as a subview of it.

Resources