Hi Alex -
sommeralex wrote:
I would like to show an uilabel as a footerView in my moreNavigationController table..
Something like this should work for you:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
// Add a footer view to the root table view of the moreNavigationController
UIViewController *moreViewController = tabBarController.moreNavigationController.topViewController;
UITableView *moreTableView = (UITableView*)moreViewController.view;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
label.text = @"Hello";
label.font = [UIFont boldSystemFontOfSize:22];
label.textAlignment = UITextAlignmentCenter;
moreTableView.tableFooterView = label;
[label release];
// print some info about the more root table view and its delegate
NSLog(@"moreViewController=%@", moreViewController);
NSLog(@"moreViewController.view=%@", moreTableView);
NSLog(@"moreViewController.view.delegate=%@", moreTableView.delegate);
NSLog(@"moreViewController.view.dataSource=%@", moreTableView.dataSource);
NSLog(@"[moreViewController respondsToSelector:@selector(tableView:viewForFooterInSection:)]=%d",
[moreViewController respondsToSelector:@selector(tableView:viewForFooterInSection:)]);
NSLog(@"[UITableViewController instancesRespondToSelector:@selector(tableView:viewForFooterInSection:)]=%d",
[UITableViewController instancesRespondToSelector:@selector(tableView:viewForFooterInSection:)]);
}
Customizing this table view isn't directly supported by the SDK, and requires references to private subclasses. However, the documentation does tell us the moreViewController is descended from UINavigationController, and the above will work as long as that controller's root view is an instance of UITableView (you could add a runtime test for that). Under the circumstances I can't guess whether your customization would be considered "use of a private class" for the purposes of approval. Maybe someone with more knowledge of the review criteria can help with that question.
I dont know how I could access / overwrite the UITableViewControllerDelegate of my moreNavigationController..
As shown in the example you won't need to access the delegate to add a footer view, so your question suggests you want to do some other customization. Are you thinking of adding a section footer instead of a table footer? I think the default table only consists of one section, so I don't know what a section footer would do for you.
If you really do need to access the delegate, the logging at the end of the example shows how things are connected. I guess you could either insert a custom delegate between the table view and the default delegate (UIMoreListController), or you might be able to implement tableView:viewForFooterInSection: in a category of UITableViewController. I might try the category first, since it would implement the delegate method without any reference to the private class instances (e.g., to avoid such references you could implement a stub in all your other table view controllers).
Here are some links that might help if you need to get into the delegate:
[http://stackoverflow.com/questions/438381/customizing-the-more-menu-on-a-tab-ba r]
[http://stackoverflow.com/questions/424899/how-to-disable-forward-class-compiler -warning-undocumented-class]
[http://seriot.ch/resources/dynamic
iPhone_headers/30/UIMoreListController.h]
Standard Disclaimer: Whenever you make use of undocumented info, you increase the risk that a new OS will break your app. Even if your project passes the review, you'll be much better prepared for the future if you've made few and relatively safe assumptions.
- Ray