1

I have a custom view (not UIButton) for navigationItem.titleView and I did a little trick to make it be fullwidth by overriding setFrame method so that it doesn't get resized automatically by the navigation controller to be shrinked ( to achieve what i want - fullwidth) I set the titleView at the viewDidLoad event.. the problem is that while the transition the navigation bar do some kind of repositioning and I see my view blinking at the transition and getting a little bit down and then blinking back to its position.. It's really irritating problem , any idea where this is coming from ?

Updated -Not solved yet-

my custom view is not a UIButton to be solved like this (thanks to @Sneak)

ios - navigationItem.titleView blinks when updated

Community
  • 1
  • 1
Aproram
  • 348
  • 1
  • 3
  • 16
  • Possible duplicate of [ios - navigationItem.titleView blinks when updated](http://stackoverflow.com/questions/28459315/ios-navigationitem-titleview-blinks-when-updated) –  Feb 16 '17 at 17:53
  • not when the view is not a UIButton .. I updated the question to clarify that@Sneak – Aproram Feb 16 '17 at 17:59
  • You can check the comment section the problem occurs with UIView too as mentioned there no real solution has been found, however, you might check other similiar issues : http://stackoverflow.com/questions/23451040/ios-7-custom-uinavigationbar-titleview-moves-when-pushing-or-popping-new-view-co and http://stackoverflow.com/questions/3681990/adjusting-navigationitem-titleviews-frame that might provide a solution , but depends on the OP code and setup –  Feb 16 '17 at 18:01
  • I have removed the flag but I will let the comment of the duplicate be here for future views. –  Feb 16 '17 at 18:09
  • @Sneak somehow they mainly talking about the problem of resizing the titleView which I mentioned that I solved with a trick but not any of them mainly exposed the other problem and couldn't find direct question about it.. – Aproram Feb 16 '17 at 18:13
  • I havn't checked into the details, but it probably has something to do with layoutSubviews and the uinavigation animations in some way.. Why don't you add the code that you set the frame with to your question might make it easier to help you in the right direction. –  Feb 16 '17 at 18:18

2 Answers2

0

Have you tried setting the autoResizingMask of your custom tileView to UIViewAutoresizingFlexibleTopMargin?

Stefan Stefanov
  • 829
  • 7
  • 23
0

In my case self.view.layoutSubviews() caused the issue. According to the official documentation, I used setNeedsLayout() instead, so the blinking has gone! (The constraint animation too, but this is another story.) Note: layoutIfNeeded() causes blinking for custom navigation as well.

Display Name
  • 4,502
  • 2
  • 47
  • 63