viewController.titleView full width blinking on transition - ios

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

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

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.

Related

In iOS, is there a way to add (overlay) a subview of a UIBarButtonItem image without it moving the buttons already in the bar?

I have my swift 5 app working and I'm now adding a 'tool tips' feature, explaining what each part of the screen does.
The approach I have taken is from an article online - add a subview of grey to dim the background, then to that, add a subview of the item being described again, so it is now highlighted, then also, add a subview of an explainer bubble to explain the item highlighted.
This works fine, so long as the UIView I'm using isn't from a UIBarButtonItem. When it is, the bar buttons underneath the grey screen move around to accomodate what they believe is another bar button being added, which causes everything to miss-align. Other buttons do not have this problem, only UIBarButtons.
Any advice is greatly appreciated. Thanks.
Are you adding the duplicate subview to the bar itself? It'd probably be better to add it to the screen rather than the bar so it doesn't affect the bar's layout. In order to get its frame relative to the view controller so you can display your duplicate in the correct position, you could use:
barButtonItem.convert(barButtonItem.bounds, to: self.view)
Assuming self is a UIViewController.

StatusBar tint and hidebaronswipe

I just want to change the color of my statusBar to follow the color of my navigationController.
I've read some posts, and now I'm understand that I'm not able to change the statusBar color, basically, I need have a view behind and change the color of that view. Ok.
So my problem is:
I have a UITableView inside a ViewController and this ViewController is embed in a NavigationController.
In the NavigationController I set the flag Hide Bars:On Swipe
When I swipe the TableView my navigationBar disappear, but it also override my view that I set to a height of 20 to simulate the StatusBar.
I found this Post, and it is the exactly my problem, I've read on this post a logical solution, but OP don't answered if it worked or not, anyway, I think that I need to work correctly with the constraints, but this solution doesnt work for me on xcode7 swift 2.0.
Any ideas?
I fount the perfectly solution on this post:
The solution marked as accepted is outdated.
Autolayout: Add constraint to superview and not Top Layout Guide?

View moves down when keyboard appears

I'm building an iPad app and there is something weird going on with the top edge of the view in relation to the status bar when the keyboard appears.
The view has a view with a segmented controller at the top with a container view below. When a button in the segmented controller is selected, the view in the container view changes.
I've done some research into the matter (it's definitely iOS 7 related) and have not found any kind of fix. I tried setting edgesForExtendedLayout to UIRectEdgeNone but that does not seem to have any effect. Even more strange, the view only moves half way to its original position when the keyboard dismisses. Any suggestions? I included screenshots below.
Original:
When keyboard appears:
After keyboard dismisses:
I can only assume your code is doing something to move the view when the keyboard appears then later disappears. So you state your view is a UIViewcontroller subclass (implying no contentOffset property). Log the values of the following before and after the keyboard action - one of them must have changed: contentInset, bounds, frame. Knowing which one will assist you in finding the problem.

navigationBar setTranslucent:NO causes UIButton to disappear

I found a strange thing. Following is just a simple demo project.
In TestViewController.m:
In AppDelegate:
When I set the translucent of the navigationBar to NO, the UIButton in the displayed viewController will not show. Conversely, if I do not set, the button will appear.
Could anyone explain it to me? I believe it is a bug of Apple.
"set the translucent of the navigationBar to NO" will make the height of UIViewController's view reduce 44 point(navigationBar's height) which make your button invisible.
Your button's frame is out of the view's bound. Adjust your uibutton's frame according to the bound of viewController's view.

UISplitView with UITabbar

I have a strange one that I can not seem to fix. I am currently working on updating my app to iOS7. This all worked in iOS6. It is an universal app and thus uses same xib files. However the iPad uses UISplitViews on some. Like I said, this all worked in iOS6 oh this all works on the iPhone too.
The problem is a grey bar at the bottom. I changed the tab bar to be opaque to move views up properly as i had some UI clipped to bottom of views and that went underneath the tab bar, sidetracked there. But if i set it back to translucent bar, it goes underneath but stretched properly. if i dont, it adds a bar. Other tabs work fine when NOT using splitview.
The UISplitviewController is added programmatically.
See attached image for better description.
This I have tried:
Added autoresize on splitview
Checked xib for subviews in the splitviews to have auto resize
Tried to force splitview to be screen bounds
Removed clips to bounds on all views
Removed autoresize subviews
Any ideas would be welcomed.
Thank you all.
UPDATE:
setting the background colour the uisplitview, it does colour the bar black. So the uisplitview is definitely stretching to it.
I subclassed UISplitViewController and added the line below to viewDidLoad and that fixed the grey line.
self.extendedLayoutIncludesOpaqueBars = YES;
I believe I have found an alternative solution for you. I have had the exact same problem, mostly because we are both doing something against Apple's Guidelines which is having a SplitViewController nested within a Tabbar controller (SplitView should be the root view). This was okay in iOS 5/6, but now in iOS 7 there are far too many side effects to achieve this.
The reason you see your view stretch completely when you set the bar to be translucent is because the bar is NOT taken into account when drawing the view. When you set translucent to false, it is then taken into account of the view and you will see that grey bar there because that's your view pretending there's a tabbar at the bottom of the screen.
And as always, a SplitViewcontroller's height cannot be changed, as it is determined by the visible window height.
I tried everything you did and then some. The real solution came from using a third-party Split View Controller.
I recommend switching over to https://github.com/mattgemmell/MGSplitViewController . This split view controller is actually one large View with container views living inside of it. Because of this, you avoid all the side effects of putting an actual split view controller within a tab bar.
If that doesn't float your boat, you could create your own solution which follows the same idea of having one UIViewController with two container views contained in it, though the people behind MGSplitViewController did a good job of that already.
This was the only way I was able to solve this issue, let me know if you find an alternative.
Instead of creating a subclass for UISplitViewController, I just added this code on my master's viewDidLoad:
self.splitViewController?.extendedLayoutIncludesOpaqueBars = true
For the controller that is the detail view of UISplitViewController you just do this:
-(UITabBarController*)tabBarController{
return nil;
}

Resources