这是代码
[self presentViewController:viewController animated:YES completion:nil];
viewController
是UIImagePickerController
当我在viewController
中展示时,navigationbar
标题已移位。
请检查图像。
有谁知道我该如何解决?
答案 0 :(得分:0)
使用以下方法自定义和更改导航栏按钮
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
//---> Code
}
有关更多信息,请参阅以下链接: Link
答案 1 :(得分:0)
你需要给titleView一个约束,从iOS11导航栏播放约束而不是之前的帧,
public extension UIView {
//From iOS 11 -> UIBarButtonItem uses autolayout instead of dealing with frames. so adding contraint for the barbuttonItem
public func applyNavBarConstraints(size: (width: CGFloat, height: CGFloat)) {
if #available(iOS 11.0, *) {
let widthConstraint = self.widthAnchor.constraint(equalToConstant: size.width)
let heightConstraint = self.heightAnchor.constraint(equalToConstant: size.height)
heightConstraint.isActive = true
widthConstraint.isActive = true
}
}}
并使用如下:
navigationItem.titleView.applyNavBarConstraints(size: (width: viewWidth, height: viewHeight))
希望这有帮助!