我有一个 SplitViewController,导航上有一个 rightbarbuttonitem,当我将方向从纵向更改为横向时,它会调整大小,我的 rightbarbuttonitem 超出范围
rightbarbuttomitem 是一个自定义视图(蓝色背景)。
我附上一些问题的图片:
我的代码:
在 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; 但没有
有什么建议吗?谢谢