1

I have a SplitViewController, with a rightbarbuttonitem on navigation that its'n resizing when I change the orientation from portrait to Landscape, my rightbarbuttonitem is out of bounds

The rightbarbuttomitem is a customview (blue color background).

I attach some pics of the problem:

NavigationcController in portrait

NavigationController in landscape

And my code:

in appdelegate:

masterViewController = [[MasterViewController alloc] initWithFeed:feedData];
    UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];

    detailViewController = [[DetailViewController alloc] initWithFeed:[feedData.secciones objectAtIndex:0]];
    [detailViewController setSeccionData:[feedData.secciones objectAtIndex:0]];
    UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
    detailNavigationController.navigationBar.tintColor = [UIColor getHexColorWithRGB:@"e2de09" alpha:1.0f];

    self.splitViewController = [[UISplitViewController alloc] init];
    self.splitViewController.delegate = detailViewController;

    masterViewController.delegate=detailViewController;
    self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];

    self.window.rootViewController=self.splitViewController;

and in my DetailViewController init the rightbarbuttonitem with a custom view:

self.navigationItem.rightBarButtonItem=nil;
NSArray *buttons;

    buttons = [NSArray arrayWithObjects:@"send",@"reload",nil];
    tools=[[Toolbar alloc] initWithFrame:CGRectMake(0, 0, 110, 30) parentController:detalleDG buttons:buttons];

tools.delegate=self;    

UIBarButtonItem *btnRight=[[UIBarButtonItem alloc] initWithCustomView:tools.view];
self.navigationItem.rightBarButtonItem=btnRight;

I tried with detailNavigationController.navigationBar.autoresizingMask=UIViewAutoresizingFlexibleWidth; or tools.view.autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; but nothing

Any suggestion? Thanks

mcalleja
  • 51
  • 4

1 Answers1

0

In this line

tools=[[Toolbar alloc] initWithFrame:CGRectMake(0, 0, 110, 30) parentController:detalleDG buttons:buttons];

Try change to this

tools=[[Toolbar alloc] initWithFrame:CGRectMake(0, 0, xxxxx.frame.size.width, xxxx.frame.size.height) parentController:detalleDG buttons:buttons];

You may change the "xxxxx" to get width and height automatically, according to your screen size of bartool or screen of your view

Did it help?

Daniel Arantes Loverde
  • 2,317
  • 2
  • 28
  • 41