UITableView rotation issue - uitableview

I have UIViewController with a UIView with UITableView inside.
All works fine in Landscape mode but when the device is rotated to Portrait, bottom half of UITableView is not accessible (can't even select any row in the bottom half or make table scroll). All rows are displayed correctly.
I am re-framing and repositioning UIView and UITableView on rotation.
Any ideas how to solve this problem?

You should adjust the autosizing in Interface Builder or in code.
I think the UITableView's height is still same with the value in Landscape mode after you rotate device to Portrait.
You can identify it by NSlog your UITableView's CGRect
NSlog(#"frame:%#",[NSStringFromCGRect(UITableView's CGRect)]);

Related

UITextField Not Responding UIScrollView Xcode 7.3

I Have a UIScrollView in my ViewController and ContentView in UIScrollView.
There are various other Views in the Content View to make understanding of the used labels and textfields more readable
Here is a screen shot to help you understand the hierarchy of the viewcontroller
All the Constraints are set properly I can see the views as they are aligned in storyboard on all size of devices, userInteraction is enabled on all the textFields and UIViews (I triple checked) still I'm not able to edit text on the textfields that are not immediately visible on the screen when the view controller is launched.
i.e. If the first three UItextFields are visible when the viewController is launched (4.0" device) they can be edited or if the first Five UItextFields are visible when the viewController is launched (5.7" device) they can be edited while the rest do not respond to user interaction
I've checked if they are in any case are overlapped or not by changing the background color of all the Labels, TextFields and Views. Nothing is overlapping anything, all are where they should be.
Content Size is set for scrollView in viewDidLayoutSubviews
-(void)viewDidLayoutSubviews {
[self.scrollView setContentSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, 1724)]; }
The Height 1724 will never change no matter the size of the device on which the code is running
Please check your contentview size or setbackground color for scrollview and contentview. Contenview size is not increasing i think.

UITableView creeps underneath button

I created a UITableView with a button underneath. When I run the app on iPad in portrait, the UITableView creeps under the button, like so:
I am clueless as to why this happens. It only happens on iPad in portrait, so I don't think it's a Xib problem.
I would very much appreciate any help with this problem.
You may need to set the UITableView's frame manually when the iPad in portrait as the UITableView may be autoresizing with traits such as sticking to the button of the screen like below. You can play around with the resize options of both the UITableView and UIButton to get this right.
To set the frame manually, set a CGRect to the frame of the element.
tableView.frame = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y,self.view.frame.size.width,self.view.frame.size.height - uploadButton.frame.size.height);
In this example, uploadButton is the UIButton at the bottom and you are resizing tableView to fill the screen except to the uploadButton at the bottom.
It looks like your tableView's content is not clipping to the bounds of the frame. Try setting clipsToBounds to YES for the tableView.
You probably need to add an autolayout contraint to keep the bottom edge of the table view and the top edge of the button a certain distance apart.

UIScrollView is automatically scrolling a random amount in iOS 5

I have an iPhone app that starts out in portrait mode. When the app is rotated to landscape a new view is pushed on using:
[self presentModalViewController:viewController animated:YES];
This landscape view contains a UIScrollView that scrolls vertically in the landscape position. The scroll view frame height is equal to the landscape height (320 points) and the content size height of the scroll view is 3 times the landscape height (so 960 points). I have vertical paging enabled, so there are 3 pages.
When the view appears, the scroll view is scrolled to the top as I expect. But in iOS 5, the scroll view then randomly jumps to some position where it is scrolled up. I've commented out my viewDidAppear method and it still does this. In iOS 6 it works fine and this doesn't happen.
Does anyone have any idea what is going on here?
So add a [scrollView setContentOffset:CGPointZero] in the viewWillAppear (or somewhere else).
Could help, but not the best way to deal with it ;-)

UITableView as subview of MKMapView

I would add a UITableView under an MKMapView, and make it resizable as the orientation of the device changes. Also, the table should hide/show as per user request.
I succeed in adding the subview, either in IB and in the code, but the problem is that when I change the orienation from portrait to landscape, the table is not properly rendered.
You can design and use another xib file for landscape mode or use autoresizingMask.

Custom headerview in grouped tableview in different orientations

I have a set up a grouped tableview where i have overridden the following delegate method:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
The headerview gets rendered and everything looks fine... in portrait mode.
If i now rotate my device the headerview is now not aligned with the table cells.
This is because the tableview has added more left and right spacing for the cells in landscape than in portrait.
From what i can tell this is not a UIViewAutoresizeMask question because the tableview cells have a varying amount of space on the left and right side depending if the iDevice is in landscape or portrait mode.
I would appreciate ANY solutions / suggestions to this problem!
UPDATE:
The problem seems to be when a tableview has a position x > 0. Notice the difference in left and right space for the table cell.
First image is in portrait mode
Second is in landscape mode

Resources