Full width UITabbarcontroler for ipad - objective-c

I have added UITabbarcontroller with 4 tabs on iPad . but in Ipad The tabs are not starting for x=0 its starting from middle.
How we can set the Uitabbar to use full width (768) of ipad so that all 4 tabs fits in full screen width
-(void) CreateTabBar
{
NSString *nibFile =#"";
NSString *imageType =#"";
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
nibFile = #"_iPhone";
imageType = #"";
}
else{
nibFile = #"_iPad";
imageType = #"_iPad";
}
SCViewController *bookCabView = [[SCViewController alloc] init];
UINavigationController *bookCabNavView = [[UINavigationController alloc]initWithRootViewController:bookCabView];
bookCabNavView.tabBarItem.image = [UIImage imageNamed:#"bookacab.png"];
// NSString *orderViewnibFile = #"";
NSString *serviceViewnibFile = #"";
NSString *contactusViewnibFile = #"";
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
//orderViewnibFile = #"EXTableViewController_iPhone";
serviceViewnibFile = #"ServiceViewController_iPhone";
contactusViewnibFile = #"ContactUsViewController_iPhone";
}
else{
// orderViewnibFile = #"EXTableViewController_iPad";
serviceViewnibFile = #"ServiceViewController_iPad";
contactusViewnibFile = #"ContactUsViewController_iPad";
}
EXTableViewController *orderView = [[EXTableViewController alloc] init];
UINavigationController *orderCabNavView = [[UINavigationController alloc]initWithRootViewController:orderView];
orderCabNavView.tabBarItem.image = [UIImage imageNamed:[#"orders" stringByAppendingFormat:#"%#.png",imageType]];
ServiceViewController *serviceView = [[ServiceViewController alloc] initWithNibName:serviceViewnibFile bundle:nil];
UINavigationController *serviceNavView = [[UINavigationController alloc]initWithRootViewController:serviceView];
serviceNavView.tabBarItem.image = [UIImage imageNamed:[#"services" stringByAppendingFormat:#"%#.png",imageType]] ;
ContactUsViewController *contactusView = [[ContactUsViewController alloc] initWithNibName:contactusViewnibFile bundle:nil];
UINavigationController *contactNavView = [[UINavigationController alloc]initWithRootViewController:contactusView];
contactNavView.tabBarItem.image = [UIImage imageNamed:[#"contactus" stringByAppendingFormat:#"%#.png",imageType]];
UITabBarItem *tab1 = [[UITabBarItem alloc] initWithTitle:#"" image:[UIImage imageNamed:#""] tag:1];
tab1.imageInsets = UIEdgeInsetsMake(0, 0, -15, 0);
[bookCabNavView setTabBarItem:tab1];
UITabBarItem *tab2 = [[UITabBarItem alloc] initWithTitle:#"" image:[UIImage imageNamed:#""] tag:2];
tab2.imageInsets = UIEdgeInsetsMake(0, 0, -15, 0);
[orderCabNavView setTabBarItem:tab2];
UITabBarItem *tab3 = [[UITabBarItem alloc] initWithTitle:#"" image:[UIImage imageNamed:#""] tag:3];
tab3.imageInsets = UIEdgeInsetsMake(0, 0, -15, 0);
[serviceNavView setTabBarItem:tab3];
UITabBarItem *tab4 = [[UITabBarItem alloc] initWithTitle:#"" image:[UIImage imageNamed:#""] tag:4];
tab4.imageInsets = UIEdgeInsetsMake(0, 0, -15,0);
[contactNavView setTabBarItem:tab4];
_tabBarCon = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
NSLog(#"%#",[#"bookacabhover" stringByAppendingFormat:#"%#.png",imageType]);
[tab1 setFinishedSelectedImage:[UIImage imageNamed:[#"bookacabhover" stringByAppendingFormat:#"%#.png",imageType]] withFinishedUnselectedImage:[UIImage imageNamed:[#"bookacab" stringByAppendingFormat:#"%#.png",imageType]]];
[tab2 setFinishedSelectedImage:[UIImage imageNamed:[#"ordershover" stringByAppendingFormat:#"%#.png",imageType]]withFinishedUnselectedImage:[UIImage imageNamed:[#"orders" stringByAppendingFormat:#"%#.png",imageType]]];
[tab3 setFinishedSelectedImage:[UIImage imageNamed:[#"serviceshover" stringByAppendingFormat:#"%#.png",imageType ]] withFinishedUnselectedImage:[UIImage imageNamed:[#"services" stringByAppendingFormat:#"%#.png",imageType ]]];
[tab4 setFinishedSelectedImage:[UIImage imageNamed:[#"contactsushover" stringByAppendingFormat:#"%#.png",imageType]] withFinishedUnselectedImage:[UIImage imageNamed:[#"contactus" stringByAppendingFormat:#"%#.png",imageType ]]];
_tabBarCon.viewControllers = [NSArray arrayWithObjects:bookCabNavView,
orderCabNavView,
serviceNavView,
contactNavView, nil];
_tabBarCon.delegate = self;
[self.view addSubview:_tabBarCon.view];
}

Related

Change color NavigationBar in detail screen CNContactPickerViewController

I have a problem like in this question, but answers don't help me. I want that colors navigation bar in seconds screen will be like a first screen. iOS 9 or later.
- (void) showAdressBookActionForIOSNineOrLater {
CNContactPickerViewController * newPicker = [[CNContactPickerViewController alloc] init];
newPicker.delegate = self;
NSDictionary *attributesNormal = [NSDictionary dictionaryWithObjectsAndKeys:
[UIFont appFont_Headline], NSFontAttributeName,
[UIColor appColor_white_0], NSForegroundColorAttributeName, nil];
//appColor_white_0 my custom color APP_RGBA(255.0f, 255.0f, 255.0f, 1.0f); appFont_Headline - [UIFont HelveticaNeueRegularFont:fontSize];
newPicker.navigationController.navigationBar.titleTextAttributes = attributesNormal;
newPicker.navigationController.navigationBar.translucent = NO;
newPicker.navigationController.navigationBar.barStyle = UIBarStyleBlack;
newPicker.navigationController.navigationBar.tintColor = [UIColor appColor_white_0];
[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:#[[UINavigationController class]]] setTintColor:[UIColor appColor_white_0]];
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:#[[UINavigationController class]]] setTintColor:[UIColor appColor_white_0]];
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:#[[UINavigationController class]]] setBarTintColor:[UIColor appColor_white_0]];
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:#[[UINavigationController class]]] setTitleTextAttributes:attributesNormal];
newPicker.predicateForEnablingContact = [NSPredicate predicateWithFormat:#"phoneNumbers.#count > 0"];
newPicker.predicateForSelectionOfContact = [NSPredicate predicateWithFormat:#"phoneNumbers.#count == 1"];
newPicker.predicateForSelectionOfProperty = [NSPredicate predicateWithFormat:#"key == phoneNumber"];
newPicker.displayedPropertyKeys = #[CNContactPhoneNumbersKey];
//
[[self currentNavigationController] presentViewController:newPicker animated:YES completion:nil];
And implement delegate methods:
- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty{
CNContact *contact = contactProperty.contact;
NSString *identify = contactProperty.identifier;
NSString * selectedNumber = #"";
for (CNLabeledValue<CNPhoneNumber*>* number in contact.phoneNumbers) {
if ([number.identifier isEqualToString:identify]) {
selectedNumber = ((CNPhoneNumber *)number.value).stringValue;
}
} [self.currentNavigationController.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker {
[self.currentNavigationController.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
Screen story:

How to add separator between tabbar icon

How to add a separator line between each icon for TabBar.
//TabbarViewController.h
#import <UIKit/UIKit.h>
#interface TabBarViewController : UITabBarController <UITabBarControllerDelegate>{ }
#end
//TabbarViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
HomeViewController *HomeViewController = [[HomeViewController alloc] init];
UploadViewController *UploadViewController = [[UploadViewController alloc] init];
MapViewController *mapviewController = [[MapViewController alloc]init];
FavouriteViewController *favouriteViewController = [[FavouriteViewController alloc]init];
HomeViewController.title = #"Home";
UploadViewController.title = #"Upload";
mapviewController.title = #"Map";
favouriteViewController.title = #"Favourite";
UINavigationController *homeNavCont = [[UINavigationController alloc] initWithRootViewController:HomeViewController];
UINavigationController *secondNavCont = [[UINavigationController alloc] initWithRootViewController:UploadViewController];
UINavigationController *thirdNavCont = [[UINavigationController alloc] initWithRootViewController:mapviewController];
UINavigationController *fourthNavCont = [[UINavigationController alloc] initWithRootViewController:favouriteViewController];
[[homeNavCont tabBarItem] setImage:[UIImage imageNamed:#“Home32”]];
[[secondNavCont tabBarItem] setImage:[UIImage imageNamed:#"camera32"]];
[[thirdNavCont tabBarItem] setImage:[UIImage imageNamed:#"Navigation32"]];
[[fourthNavCont tabBarItem] setImage:[UIImage imageNamed:#"Faviourte32"]];
HomeViewController.tabBarItem.selectedImage = [[UIImage imageNamed:#"Home32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
UploadViewController.tabBarItem.selectedImage = [[UIImage imageNamed:#"camera32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
mapviewController.tabBarItem.selectedImage = [[UIImage imageNamed:#"Navigation32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
favouriteViewController.tabBarItem.selectedImage = [[UIImage imageNamed:#"Faviourte32"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
self.viewControllers=[NSArray arrayWithObjects:homeNavCont,secondNavCont,thirdNavCont,fourthNavCont,nil];
self.delegate = self;
[self setSelectedIndex:0];
}
Need your advice for adding separator in between icons for tabbar.

UItabBar from second view controller but all viewController have UInavigation with back to firstViewController issue

Let me explain my application first. I have six view controller
MenuViewController
FirstViewController
SecondViewController
ThirdViewController
FourthViewController
FifthViewController
All these 6 ViewControllers are in navigationController. I want to show my "MenuViewController" first at the starting time of the app, after splash screen, which contains 5 buttons (For :FirstViewController, SecondViewController, ThirdViewController, FourthViewController, FifthViewController). In this viewController there will be no TabBarController at the bottom of the page. But other viewController will be in tabbarController. When i touch one of those five button in menuviewController, it will bring me to that corresponding view controller where i can find the tabbarController at the bottom. I can do it with custom coding, positioning and setting image behind them. Here is the code:
AppDelegate.h :
#interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>
{
UIImageView *firstTabImageView;
UIImageView *secondTabImageView;
UIImageView *thirdTabImageView;
UIImageView *fourthTabImageView;
UIImageView *fifthTabImageView;
UIImage *firstTabImage;
UIImage *firstTabActiveImage;
UIImage *secondTabImage;
UIImage *secondTabActiveImage;
UIImage *thirdTabImage;
UIImage *thirdTabActiveImage;
UIImage *fourthTabImage;
UIImage *fourthTabActiveImage;
UIImage *fifthTabImage;
UIImage *fifthTabActiveImage;
}
#property (strong, nonatomic) MenuViewController *menuViewController;
#property (strong, nonatomic) UINavigationController *navigationController;
#property (retain, nonatomic) IBOutlet UITabBarController *tabBarController;
AppDelegate.m :
-(void)makeTabBar
{
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;
FirstViewController *firstViewController =[[FirstViewController alloc] initWithNibName:#"FirstViewController" bundle:nil];
UINavigationController *firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
firstNavigationController.tabBarController.tabBar.tag = 0;
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
UINavigationController *secondNavigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
secondNavigationController.tabBarController.tabBar.tag = 1;
ThirdViewController *thirdViewController = [[ThirdViewController alloc] initWithNibName:#"ThirdViewController" bundle:nil];
UINavigationController *thirdNavigationController = [[UINavigationController alloc] initWithRootViewController:thirdViewController];
thirdNavigationController.tabBarController.tabBar.tag = 2;
FourthViewController *fourthViewController = [[FourthViewController alloc] initWithNibName:#"FourthViewController" bundle:nil];
UINavigationController *fourthNavigationController = [[UINavigationController alloc] initWithRootViewController:fourthViewController];
fourthNavigationController.tabBarController.tabBar.tag = 3;
FifthViewController *fifthViewController = [[FifthViewController alloc] initWithNibName:#"FifthViewController" bundle:nil];
UINavigationController *fifthNavigationController = [[UINavigationController alloc] initWithRootViewController:fifthViewController];
fifthNavigationController.tabBarController.tabBar.tag = 4;
menuNavigationController.navigationBarHidden = YES;
firstNavigationController.navigationBarHidden = YES;
secondNavigationController.navigationBarHidden = YES;
thirdNavigationController.navigationBarHidden = YES;
fourthNavigationController.navigationBarHidden = YES;
fifthNavigationController.navigationBarHidden = YES;
NSArray *viewControllers =[[NSArray alloc]initWithObjects:
firstNavigationController,
secondNavigationController,
thirdNavigationController,
fourthNavigationController,
fifthNavigationController,
nil];
firstTabImage = [UIImage imageNamed:#"MenuTabImage.png"];
firstTabActiveImage = [UIImage imageNamed:#"MenuTabImage_Active.png"];
secondTabImage = [UIImage imageNamed:#"TVGuideTabImage.png"];
secondTabActiveImage = [UIImage imageNamed:#"TVGuideTabImage_Active.png"];
thirdTabImage = [UIImage imageNamed:#"FirstRankTabImage.png"];
thirdTabActiveImage = [UIImage imageNamed:#"FirstRankTabImage_Active.png"];
fourthTabImage = [UIImage imageNamed:#"FavoriteTabImage.png"];
fourthTabActiveImage = [UIImage imageNamed:#"FavoriteTabImage_Active.png"];
fifthTabImage = [UIImage imageNamed:#"RegistrationTabImage.png"];
fifthTabActiveImage = [UIImage imageNamed:#"RegistrationTabImage_Active.png"];
CGRect frame = CGRectMake(0, 0, 320, 52);
UIView *viewa = [[UIView alloc] initWithFrame:frame];
UIImage *tabBarBackgroundImage = [UIImage imageNamed:#"Tab_Back.png"];
UIColor *color = [[UIColor alloc] initWithPatternImage:tabBarBackgroundImage];
[viewa setBackgroundColor:color];
if(IS_IPHONE_5)
{
[[self.tabBarController tabBar] insertSubview:viewa atIndex:1];
firstTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 519, 64, 49)];
secondTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(64, 519,64, 49)];
thirdTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(128, 519,64, 49)];
fourthTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(192, 519, 64, 49)];
fifthTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(256, 519, 64, 49)];
}
else
{
[[self.tabBarController tabBar] insertSubview:viewa atIndex:0];
firstTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 431, 64, 49)];
secondTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(64, 431,64, 49)];
thirdTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(128, 431,64, 49)];
fourthTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(192, 431, 64, 49)];
fifthTabImageView = [[UIImageView alloc]initWithFrame:CGRectMake(256, 431, 64, 49)];
}
firstTabImageView.image = firstTabActiveImage;
secondTabImageView.image = secondTabImage;
thirdTabImageView.image = thirdTabImage;
fourthTabImageView.image = fourthTabImage;
fifthTabImageView.image = fifthTabImage;
[self.tabBarController.view addSubview:firstTabImageView];
[self.tabBarController.view addSubview:secondTabImageView];
[self.tabBarController.view addSubview:thirdTabImageView];
[self.tabBarController.view addSubview:fourthTabImageView];
[self.tabBarController.view addSubview:fifthTabImageView];
self.tabBarController.delegate=self;
self.tabBarController.selectedIndex=0;
[tabBarController setViewControllers:viewControllers animated:NO];
}
- (void)tabBarController:(UITabBarController *)tabBarController1 didSelectViewController:(UIViewController *)viewController1
{
if (viewController1 == [tabBarController1.viewControllers objectAtIndex:0])
{
firstTabImageView.image = [UIImage imageNamed:#"MenuTabImage_Active.png"];
secondTabImageView.image = [UIImage imageNamed:#"TVGuideTabImage.png"];
thirdTabImageView.image = [UIImage imageNamed:#"FirstRankTabImage.png"];
fourthTabImageView.image = [UIImage imageNamed:#"FavoriteTabImage.png"];
fifthTabImageView.image = [UIImage imageNamed:#"RegistrationTabImage.png"];
}
else if (viewController1 == [tabBarController1.viewControllers objectAtIndex:1])
{
firstTabImageView.image = [UIImage imageNamed:#"MenuTabImage.png"];
secondTabImageView.image = [UIImage imageNamed:#"TVGuideTabImage_Active.png"];
thirdTabImageView.image = [UIImage imageNamed:#"FirstRankTabImage.png"];
fourthTabImageView.image = [UIImage imageNamed:#"FavoriteTabImage.png"];
fifthTabImageView.image = [UIImage imageNamed:#"RegistrationTabImage.png"];
}
else if (viewController1 == [tabBarController1.viewControllers objectAtIndex:2])
{
firstTabImageView.image = [UIImage imageNamed:#"MenuTabImage.png"];
secondTabImageView.image = [UIImage imageNamed:#"TVGuideTabImage.png"];
thirdTabImageView.image = [UIImage imageNamed:#"FirstRankTabImage_Active.png"];
fourthTabImageView.image = [UIImage imageNamed:#"FavoriteTabImage.png"];
fifthTabImageView.image = [UIImage imageNamed:#"RegistrationTabImage.png"];
}
else if (viewController1 == [tabBarController1.viewControllers objectAtIndex:3])
{
firstTabImageView.image = [UIImage imageNamed:#"MenuTabImage.png"];
secondTabImageView.image = [UIImage imageNamed:#"TVGuideTabImage.png"];
thirdTabImageView.image = [UIImage imageNamed:#"FirstRankTabImage.png"];
fourthTabImageView.image = [UIImage imageNamed:#"FavoriteTabImage_Active.png"];
fifthTabImageView.image = [UIImage imageNamed:#"RegistrationTabImage.png"];
}
else if (viewController1 == [tabBarController1.viewControllers objectAtIndex:4])
{
firstTabImageView.image = [UIImage imageNamed:#"MenuTabImage.png"];
secondTabImageView.image = [UIImage imageNamed:#"TVGuideTabImage.png"];
thirdTabImageView.image = [UIImage imageNamed:#"FirstRankTabImage.png"];
fourthTabImageView.image = [UIImage imageNamed:#"FavoriteTabImage.png"];
fifthTabImageView.image = [UIImage imageNamed:#"RegistrationTabImage_Active.png"];
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self makeTabBar];
MenuViewController *menuViewController = [[MenuViewController alloc] initWithNibName:#"MenuViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:menuViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
I use this code for every "IBAction" with different index :
For example : "FirstViewController" with "index: 0"
- (IBAction)GotoFirstViewController:(id)sender
{
AppDelegate *appdelegte = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[[[appdelegte navigationController] view]removeFromSuperview];
[[appdelegte window] addSubview:[[appdelegte tabBarController] view]];
[[appdelegte tabBarController] setSelectedIndex:0];
}
Now the problem is after going to a ViewController, and come back to "MenuViewController"
Useing this code :
-(IBAction)goBack:(id)sender
{
menuViewController = [[MenuViewController alloc] initWithNibName:#"MenuViewController" bundle:nil];
[self.navigationController pushViewController:menuViewController animated:YES];
}
I cannot go to another ViewController (any of five) pressing the same button.
If any one know, when the tabbar is setup from "seceondViewController (Here : firstViewController)" then after coming to the "firstViewController ( here : menuViewController)" from other ViewController, how to go again in the other ViewController which are connected with tabbar, please share with me.
Thanks a lot for reading this post and a lot thanks in advance.
- Tulon
- (void)addToolBarToView:(UIToolbar *)rootToolBar currentView:(UIViewController *)currentView{
CGRect rect = currentView.view.frame;
rootToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, rect.size.height-44, rect.size.width, 44)];
[rootToolBar setBarStyle:UIBarStyleDefault];
[rootToolBar sizeToFit];
UIBarButtonItem *searchBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"icon_ricerca.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(showSearch)];
UIBarButtonItem *cartBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"icon_shopping_cart.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(showCart)];
UIBarButtonItem *settingBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"icon_settings.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(showSettings)];
UIBarButtonItem *favoriteBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"icon_preferiti.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(showFavorites)];
UIBarButtonItem *savedBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"icon_save.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(showSaved)];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
NSArray *barItems = [NSArray arrayWithObjects:searchBtn, flexSpace, cartBtn, flexSpace, favoriteBtn, flexSpace, settingBtn, flexSpace, savedBtn ,nil];
[rootToolBar setItems:barItems animated:YES];
[currentView.view addSubview:rootToolBar];
}
Add this code at your AppDelegate.m
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
self.tabBarController.selectedViewController=viewController;
return YES;
}
Based on apple documentation UITabBar is a subclass of UIViewController and can be a child View..! But it must be the UIWindow rootController if not your app will crash!!! I had the same problem at the end I had to use UIToolBar to do the same thing.. though with a very hard work on customization.

Couldn't change the orientation in SplitViewController

I am not much familiar with iPad app SplitViewController. I have used the SplitViewController in my app. When change the orientation from portrait to landscape, Masterview is hiding from splitView. Could you please any help me to sort out this issue.
I have attached my source for your reference.
Creating SplitViewController:
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
menuViewController = [[MainMenuViewController alloc] initWithNibName:#"MainMenuViewController" bundle:nil];
UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:menuViewController] ;
masterNavigationController.navigationBar.barStyle = UIBarStyleBlack;
MainMenuDetailViewController *detailViewController = [[MainMenuDetailViewController alloc] initWithNibName:#"MainMenuDetailViewController" bundle:nil] ;
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController] ;
detailNavigationController.navigationBar.barStyle = UIBarStyleBlack;
self.splitViewController = [[UISplitViewController alloc] init];
[self.splitViewController.view setBackgroundColor:[UIColor whiteColor]];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];
DetailView Page:
pragma mark -
pragma mark Split view support
(void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController )aViewController withBarButtonItem:(UIBarButtonItem)barButtonItem forPopoverController: (UIPopoverController*)pc {
barButtonItem.title = NSLocalizedString(#"Menu", #"Menu");
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = pc;
appDelegate.rootPopoverButtonItem = barButtonItem;
appDelegate.masterPopoverController = pc;
}
// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
MasterView Button Tap:
[appDelegate.splitViewController viewWillDisappear:YES];
[UIView beginAnimations: #"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]];
[viewControllerArray removeLastObject];
if( viewMenu.hidden == YES) // Main Menu
{
if(btnMenu.tag == 1) // Service Report Form
{
if (!self.mainMenuDetailViewController) {
self.mainMenuDetailViewController = [[MainMenuDetailViewController alloc] initWithNibName:#"MainMenuDetailViewController" bundle:nil];
}
[viewControllerArray addObject:self.mainMenuDetailViewController];
appDelegate.splitViewController.delegate = self.mainMenuDetailViewController;
}
if(btnMenu.tag == 4) // Signout
{
[self.navigationItem setLeftBarButtonItem:nil];
[appDelegate SignOut];
btnSignOut.frame = CGRectMake(24,275,272,50);
}
else if(btnMenu.tag == 2) // Inquiries
{
if (!self.inquiryViewController) {
self.inquiryViewController = [[InquiryViewController alloc] initWithNibName:#"InquiryViewController" bundle:nil] ;
}
[viewControllerArray addObject:self.inquiryViewController];
appDelegate.splitViewController.delegate = self.inquiryViewController;
}
else if(btnMenu.tag == PageMasterSync)
{
if (!self.mastSyncViewController) {
self.mastSyncViewController = [[MastSyncViewController alloc] initWithNibName:#"MastSyncViewController" bundle:nil] ;
}
appDelegate.splitViewController.delegate = self.mastSyncViewController;
[viewControllerArray addObject:self.mastSyncViewController];
}
else if(btnMenu.tag == PageServiceReport)
{
if(!self.srListViewController)
self.srListViewController = [[SRListViewController alloc] initWithNibName:#"SRListViewController" bundle:nil];
appDelegate.splitViewController.delegate = srListViewController;
[viewControllerArray addObject:self.srListViewController];
}
}
}
[[appDelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO];
if(btnMenu.tag == PageReview && !viewMenu.hidden)
[self.reviewViewController loadServiceReport];
[appDelegate.splitViewController viewWillAppear:YES];
[viewControllerArray release];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
[UIView commitAnimations];
With regards
Senthil

Bottom half of UITabbar is not responding to clicks

I have created a UITabbar with 3 items and placed it on a UIScrollView
When I click the buttons of the tabbar they do not respond in the bottom half.
The upper area is working fine.
When clicking in the area just above the tabbar the tabs are also switched.
What can be wrong?
How can i correct this misalignment of the clickable button area?
In viewDidLoad:
[super viewDidLoad];
scroll.frame = CGRectMake(0, 20, 320, 460);
scroll.pagingEnabled = YES;
scroll.contentSize = CGSizeMake(320 * 2, 460);
scroll.showsHorizontalScrollIndicator = NO;
scroll.showsVerticalScrollIndicator = NO;
scroll.scrollsToTop = NO;
scroll.delegate = self;
scroll.pagingEnabled = YES;
viewNavController1 = [[viewNavController1 alloc] init];
ctrl = [[UITabBarController alloc] init];
ViewController1 *viewC1= [[ViewController1 alloc] initWithNibName:#"ViewController1" bundle:nil];
UINavigationController *control = [[UINavigationController alloc] initWithRootViewController:viewC1];
viewC1.title = #"Title1";
[viewC1 release];
ViewController2 *viewC2 = [[ViewController2 alloc] initWithNibName:#"ViewController2" bundle:nil];
UINavigationController *control2 = [[UINavigationController alloc] initWithRootViewController:viewC2];
viewC2.title = #"Title2";
[viewC2 release];
UINavigationController *control3 = [[UINavigationController alloc] init];
ViewController3 *viewC3 = [[ViewController3 alloc] initWithNibName:#"ViewController3" bundle:nil];
[control3 pushViewController:viewC3 animated:NO];
viewC3.title = #"Title3";
[viewC3 release];
[ctrl setViewControllers:[NSArray arrayWithObjects:control,control2,control3,nil]];
CGRect frame = scroll.frame;
frame.origin.x = frame.size.width * 0;
frame.origin.y = 0;
viewNavController1.view.frame = frame;
viewC4 = [[ViewController4 alloc] initWithNibName:#"ViewController4" bundle:nil];
[viewNavController1 pushViewController:viewC4 animated:NO];
[scroll addSubview:viewNavController1.view];
frame = scroll.frame;
frame.origin.x = frame.size.width * 1;
frame.origin.y = 0;
ctrl.view.frame = frame;
[scroll addSubview:ctrl.view];
[scroll scrollRectToVisible:CGRectMake(320, 0, 320, 460) animated:NO];
UITabBarItem *itm = [ctrl.tabBar.items objectAtIndex:0];
itm.image = [UIImage imageNamed:#"img1.png"];
itm = [ctrl.tabBar.items objectAtIndex:1];
itm.image = [UIImage imageNamed:#"img2.png"];
itm = [ctrl.tabBar.items objectAtIndex:2];
itm.image = [UIImage imageNamed:#"img3.png"];
[control release];
[control2 release];
[control3 release];
The problem was that the UITabbarController did not have its view added as the root view of the windows. Which it apparently assumes.
so I had to trick it using:
[vc setWantsFullScreenLayout:YES];
vc is the main ViewController holding the scrollview containing the UITabbarController.
See Offset on UIWindow addSubview for more explanations.