Good night / morning / afternoon / evening
As you can see from the title of the article, I will tell you about how, having spent a minimum of time and effort, turn the iPhone UITabBarController into an iPad `“ UISplitViewController ”
For this we need: a project (for iPad) from
my previous story , a xib file (for iPhone) with UITabBarController and a controller class for it. I had the first. As for the second and third, I quickly created xib in Interface Builder and gave it the straightforward name iPhoneTabBar.xib.

')
Since our UITabBarController was created only for demonstration, I ...
Generally what the
hell he can not do. The only thing I added is UIAlertView, which pops up when you click the Click Me button (located on one of the tabs). The code is below.
iPhoneTabBar.h#import <UIKit/UIKit.h>
@ interface iPhoneTabBar : UITabBarController { }
-(IBAction) showAlert;
@end
* This source code was highlighted with Source Code Highlighter .
iPhoneTabBar.m#import "iPhoneTabBar.h"
@implementation iPhoneTabBar
-(IBAction) showAlert{
UIAlertView* alert= [[UIAlertView alloc] initWithTitle: @"Title"
message: @"message"
delegate :nil
cancelButtonTitle: @"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
- ( void )didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- ( void )viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// eg self.myOutlet = nil;
}
- ( void )dealloc {
[super dealloc];
}
@end
* This source code was highlighted with Source Code Highlighter .
Well, let's start. Having opened the project from my previous article, add our TabBar to it. It will look like this:

Now we modify our MasterViewController class.
In the header file, add an IBOutlet variable - a pointer to the iPhoneTabBar controller class. This will allow us, when a user selects a menu item on the left side of SplitViewControllera, to inform UITabBar that they need to show the corresponding page + something else.
MasterViewController.h#import <UIKit/UIKit.h>
@ class DetailViewController;
@ class iPhoneTabBar;
@ interface MasterViewController : UITableViewController {
IBOutlet DetailViewController* detailViewController;
IBOutlet iPhoneTabBar* iphoneTabBar;
}
@end
* This source code was highlighted with Source Code Highlighter .
And now the most important thing: in the implementation of the MasterViewController class, add (or replace, if it was before) the viewDidLoad method, which will be called immediately after loading the view. In it, we place on our detailView the contents (to be more precise, the view itself) UITabBarController'a, after hiding the UITabBar panel, which is below
-( void ) viewDidLoad{
[super viewDidLoad];
iphoneTabBar.view.frame=CGRectMake(0, 0, detailViewController.view.frame.size.width,detailViewController.view.frame.size.height+49);
iphoneTabBar.tabBar.hidden=TRUE;
[detailViewController.view insertSubview:iphoneTabBar.view atIndex:1];
}
* This source code was highlighted with Source Code Highlighter .
When the user selects one of the table cells (didSelectRowAtIndexPath), we should switch to the new UITabBar page
- ( void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
iphoneTabBar.selectedViewController = [iphoneTabBar.viewControllers objectAtIndex:indexPath.row];
}
* This source code was highlighted with Source Code Highlighter .
Final touches: opening iPhoneTabBar.xib and AlternativeSplitViewController.xib in InterfaceBuilder by dragging (or simply copying) from the first to the second UITabBarController. You also need to associate our IBOutlet variable with this UITabBarController

That's all)
Some screenshots below:



Pros: minimum porting time + ease of implementation.
Cons :
crutch ... nothing to add.
source link
here and
hereMdja, some strange article came out ...