Automatically customize content inserts for views with custom tab bar

I created a custom tab bar controller. It is very similar to the UITabBarController , but with a more advanced layout for the UITabBar .

How do I customize bottom content inserts for the views displayed in my custom tab bar controller? For example, if I display a UITableView in my custom tab bar controller, I can manually configure content inserts like this.

 self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0); self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0); 

However, the problem becomes more complex if I click another view on this table view, similar to the collection view. Is there a way to get these views to automatically configure their content inserts, as they do in the default implementation of UITabBarController ?

+7
ios objective-c uiscrollview uitabbarcontroller
source share
1 answer

We recently did something similar in our application, and ended up just looking at the container that contains any content that we are going to display in the controller. The advantage of this approach is that you can add any restrictions that you want to display in the container (for example, the bottom pad between the container and the tab bar).

View of the container with the bottom indentation on the tab bar.

Edit: Did not understand the question

You can simply verify that the content view can set theContentInset:

 - (void)setContentInset:(UIEdgeInset)insets { if ([self.contentView respondsToSelector:@selector(setContentInset:)]) { [self.contentView setValue:insets forKey:@"contentInset"]; } } 
+2
source share

All Articles