SoFunction
Updated on 2025-04-12

How to fix the problem of UITableview misalignment in iOS

Problem description:

Question 1:When a navigation navigation enters UITabBarController   There are multiple pages in the TabBar, and there is a tableView under the page. When I enter the Tableview, the two rows of tables above are blocked. When I click in and return, I don’t see it when I find that the upward table is 44PT, which happens to be a top bar. (But pushing from the parent page of this page to this page is still blocked, but I will not be blocked when I pop it from the child page of this page)

Question 2:I encountered a problem when doing UISearchBar, UISearchDisplayController. When clicking on the search bar, the position of the shadow part is deviated.

- (void)viewDidLoad { 
 [super viewDidLoad]; 
 // = NO; 
  = UIRectEdgeNone; 
} 

In iOS 7, Apple introduced a new attribute called [UIViewController setEdgesForExtendedLayout:], its default value is UIRectEdgeAll. When your container is a navigation controller, the default layout will start at the top of the navigation bar. This is why all UI elements drifted up by 44pt.

A quick way to fix this problem is in the method- (void)viewDidLoadAdd the following line of code:

 = UIRectEdgeNone; 

This problem is fixed.

The above is the method of fixing the UITableview misalignment problem in iOS introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!