我有一个SplitViewController,在导航上有一个右栏按钮,当我将方向从纵向更改为横向时,它的大小调整,我的右栏按钮超出范围
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中使用自定义视图初始化右栏按钮:
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; 但没什么
有什么建议吗?感谢
答案 0 :(得分: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屏幕尺寸或视图屏幕自动更改“xxxxx”以获得宽度和高度
有帮助吗?