I'm in the process of customizing the 'More' view in my app's UITabBarController.
From what I see in the docs there is precious little support for customizing it. There is only a read-only property of the UITabBarController called 'moreNavigationController' that points to a UINavigationController.
This allows us at least to customize it's UINavigationBar. Customizing the table view it presents in the first view controller is a little trickier.
On other questions here on SO and elsewhere, I've seen that all talk revolves around messing with the internal structure of the moreNavigationController (for example observing that the first view controller in the stack is a UITableViewController, swapping out it's data controller, etc.). Problem is all these methods make assumptions about how undocumented code in the API behaves, assumptions that are hardly future-proof.
The only alternative I see here is to roll my own custom "more controller" (optionally ditching the edit functionality to keep the implementation fairly simple) and using it as the fifth view controller in the tab. Of course care must be taken to assign the subsequent view controllers to the custom "more controller" not to the UITabBarController directly (subclassing the UITabBarController may be required to enforce this rule).
Which approach would you choose? What other solutions would you suggest?
UIViewController *tbMore =
((UIViewController*)
[self.moreNavigationController.viewControllers objectAtIndex:0]);
int nRows = [((UITableView *)tbMore.view) numberOfRowsInSection:0];
for (int i = 0; i < nRows; i++)
{
UITableViewCell *c =
[((UITableView *)tbMore.view)
cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
// Do any additional customization here!
}
I would choose to roll my own custom controller for 3 reasons:
moreViewController
is controlled by UIKit
. Externally, it is very hard to customize some views and control them directly. There will be unpredictable methods and layer definitions in moreViewController
. It can't be basic UITableViewController
. I think customizing classes that have delegates is more efficient.
If you customize moreViewController
, you may have to release a new version of your app each time Apple releases new iOS. The developers of moreViewController
at Apple may change entire class to something else. So your application will stop responding.
My own class, my own home. I can do whatever I want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With