在iOS8中设置UIPopoverController大小的正确方法
iOS7中的是
[UIPopoverController setContentViewController:(UIViewController *) animated:(BOOL)];
但现在它不起作用
提前致谢
编辑:要把我的代码放在这里,两个结果(iOS7.1和iOS8)
DetalleTarjetaVC *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"DetalleTarjetaVC"];
UINavigationController *navController;
navController = [[UINavigationController alloc] initWithRootViewController:controller];
navController.toolbarHidden = FALSE;
navController.navigationBar.translucent = FALSE;
navController.toolbar.translucent = FALSE;
navController.navigationBar.barTintColor = UIColorFromRGBWithAlpha(toolbarTintColor, 0.95);
navController.navigationBar.barStyle = UIBarStyleBlack;
navController.toolbar.barTintColor = UIColorFromRGBWithAlpha(toolbarTintColor, 0.95);
navController.toolbar.barStyle = UIBarStyleBlack;
controller.view.backgroundColor = UIColorFromRGBWithAlpha(0XFFFFFF, 1);
tarjetasPopover = [[UIPopoverController alloc] initWithContentViewController:navController];
CGRect rect = button.frame;
CGPoint coord = [button convertPoint:button.frame.origin toView:self.tableView];
rect.origin.y = coord.y -20;
[tarjetasPopover setPopoverContentSize:CGSizeMake(530, 400) animated:YES];
[tarjetasPopover presentPopoverFromRect:rect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
答案 0 :(得分:2)
可以帮到你的东西
int iOSVersion = [[[UIDevice currentDevice]systemVersion] intValue];
if (iOSVersion >= 8) {
controller.preferredContentSize = CGSizeMake(530, 312);
}
else{
[tarjetasPopover setPopoverContentSize:CGSizeMake(530, 400) animated:YES];
}
我降低了iOS8的88.0高度,因为您必须考虑工具栏和导航控制器的宽度(每个44px)以获得相同的尺寸
答案 1 :(得分:0)
该方法尚未在iOS8中替换。你只需要在之前分配一个等额:
UIPopoverController *yourPopoverController = [[UIPopoverController alloc] init];
然后你可以使用:
[yourPopoverController setContentViewController:yourViewController animated:YES];
或者您可以轻松地在UIPopoverController Init上传递viewController:
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:yourViewController];
希望有所帮助。