How to Properly Refresh a Uinavigationbar

Auto Resizing UINavigationBar on rotation to landscape

[[UINavigationBar appearance] setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin];

But you didn't say flexible height. Yet height, as I understand it, is the very feature you wish to be flexible.

UIRefreshControl hidden / obscured by my UINavigationController's UINavigationBar

For those targeting iOS 7, there seems to be a new issue present where the UIRefreshControl is drawn behind the UITableView's backgroundView. I experienced this both when initializing the UIRefreshControl programatically and from a storyboard. A simple workaround is to update the zPosition of the UIRefreshControl in viewDidLoad of your UITableViewController:

self.refreshControl.layer.zPosition = self.tableView.backgroundView.layer.zPosition + 1;

Navigation bar title updates too late (Swift)

Try this code:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "CategorySelected") {
DispatchQueue.main.async {
let vc = segue.destination as! SearchOrgTableViewController
vc.category = selectedCategory
vc.title = category.name } }
}

Prefer Large Titles and RefreshControl not working well

At the end what worked for me was:

  • In order to fix the RefreshControl progress bar disappearing bug with large titles:

    self.extendedLayoutIncludesOpaqueBars = true
  • In order to fix the list offset after refreshcontrol.endRefreshing():

    let top = self.tableView.adjustedContentInset.top
    let y = self.refreshControl!.frame.maxY + top
    self.tableView.setContentOffset(CGPoint(x: 0, y: -y), animated:true)

How to transition smoothly from translucent to opaque UINavigationBar iOS?

I finally found a decent solution!

There doesn't appear to be a proper way to smoothly transition from an opaque to transparent UINavigationBar BUT you can transition smoothly from a view controller with a visible status bar to one that has a hidden status bar.

This opens up a possible workaround which is to add the following in the viewWillAppear of VC2 from above:

[self.navigationController setNavigationBarHidden:YES animated:YES];

Once you have that, manually add a UINavigationBar to your xib and configure it to be transparent (and add all necessary UIBarButtonItem and views).

If everything is hooked up properly transitioning from VC1 to VC2 will hide the UINavigationBar at the same speed as the view transition and VC2 will show up with it's embedded UINavigationBar

Note: To make this work properly you'll have to make sure that in the viewWillAppear of View Controllers that can be accessed from VC2 you reset the UINavigationBar to be visible (if necessary) via:

[self.navigationController setNavigationBarHidden:NO animated:YES];

TL;DR - manually add a UINavigationBar to your transparent nav bar view controller and in its viewWillAppear hide the default one via setNavigationBarHidden:animated:



Related Topics



Leave a reply



Submit