1

我有一个 SplitViewController,导航上有一个 rightbarbuttonitem,当我将方向从纵向更改为横向时,它会调整大小,我的 rightbarbuttonitem 超出范围

rightbarbuttomitem 是一个自定义视图(蓝色背景)。

我附上一些问题的图片:

NavigationcController 纵向

横向导航控制器

我的代码:

在 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;

并在我的 DetailViewController 中使用自定义视图初始化 rightbarbuttonitem:

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;

我试过 detailNavigationController.navigationBar.autoresizingMask=UIViewAutoresizingFlexibleWidth; 或 tools.view.autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 但没有

有什么建议吗?谢谢

4

1 回答 1

0

在这一行

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

尝试改变这个

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

您可以根据 bartool 的屏幕大小或视图的屏幕更改“xxxxxx”以自动获取宽度和高度

有帮助吗?

于 2012-04-10T13:35:51.053 回答