I'm working on a project in swift for iPad
.
Have placed an image view in Navigation bar title view from story board.
The title view is displaying as expected in iOS 10
and below.
The same project when i run in iOS 11 simulators and the physical devices Navigation bar is not showing the title view, any leads would be appreciated.
Asked
Active
Viewed 2,207 times
0

iPatel
- 46,010
- 16
- 115
- 137

Naresh Reddy M
- 1,096
- 1
- 10
- 27
-
any code on how you did this would be appreciated. – Siyavash Sep 29 '17 at 11:52
-
No Code to add title view, That was added from Storyboard – Naresh Reddy M Sep 29 '17 at 12:30
-
Possible duplicate of [iOS 11 Navigation TitleView misplaced](https://stackoverflow.com/questions/46578752/ios-11-navigation-titleview-misplaced) – Dania Delbani Dec 10 '17 at 12:12
2 Answers
4
Create a custom view and override below method in the custom title view class to update view frame size at runtime.
Obj-C
-(CGSize)intrinsicContentSize
{
[super intrinsicContentSize];
return UILayoutFittingExpandedSize;
}
Swift
override var intrinsicContentSize: CGSize {
return UILayoutFittingExpandedSize
}
Check and let me know is it working for you or not ?

Naresh Reddy M
- 1,096
- 1
- 10
- 27

Chandrapandian J
- 91
- 6
-
Just debug with hierarchy view option and you come to know frame size of custom titleView is zero in ios 11 alone. To update frame size at runtime you need to call this method. – Chandrapandian J Oct 23 '17 at 10:29
-
Oh is it? does this code shows any impact on the existing behavior for iOS 10 and below? or it's specific to iOS 11 only? – Naresh Reddy M Oct 23 '17 at 10:31
-
I hope, No impact on existing behavior of iOS 10 and below. Please check and let me know. – Chandrapandian J Oct 23 '17 at 10:35
0
Maybe this can help you
let widthConstraint = view.widthAnchor.constraint(equalToConstant: width)
let heightConstraint = view.heightAnchor.constraint(equalToConstant:height)
widthConstraint.isActive = true
heightConstraint.isActive = true
view
is the view that you use as a custom title view. And width
and height
is the size that you want to use. You can use:
let width = view.frame.width
let height = view.frame.height

Alberto Cantallops
- 314
- 6
- 15