Tweak UI Navigation on iOS 11 - ios

I have a problem with a navigation bar in iOS 11.
I use this code:
[UINavigationBar appearance].prefersLargeTitles = YES;
...to set a new style for my app. It works well untill a user pull to refresh on the table view; then it breaks.
This is before pull-to-refresh:
...and this is _after:
Note: I use the table view controller's built-in pull-to-refresh control.
I searched for a solution but it still eludes me. If someone knows how to fix this please drop some advice.
Thanks for the support :)

I have catch this bug too, and we have found the solution.
You must constraint your UITableView to superview (contentView of your view controller), after that large title and all related views starts to work correct.
Like this:

While I do not claim this is the solution for every situation the error occurs in, setting the navigationBar's isTranslucent property to true (which is also the default value) fixed the problem for me.
If you want to keep your navigation bar non-translucent you can use the following code:
navigationBar.barStyle = .blackOpaque

Related

iOS13 - UITableView + UISearchController with custom hidesSearchBarWhenScrolling behavior

On iOS 13, if you set hidesSearchBarWhenScrolling to true, the view controller will hide the search bar, and you have to scroll down to reveal it.
If you set it to false then it is immediately shown and it won't disappear.
I think this is a reasonable behavior, assuming that the end users are all versed in the way the Apple products work. Given that's not seem to be the case, I would like to show the searchbar at first visit, but then if the user starts scrolling up, the search bar is hidden. So this is a mixed behavior of the true/false.
This worked on iOS12, where I set the hidesSearchBarWhenScrolling = true in the viewDidAppear, but now on iOS 13 it's not the case. The table scrolls, but the searchbar stays on top instead of scrolling it together with the tableview(btw this is only because the screen is not rendered again).
Any idea how to go about it? I tried changing the content offset of the tableview, but no luck really.
For me it worked after adding following lines in viewDidLoad() method:
navigationController!.navigationBar.sizeToFit()
No need to specify hidesSearchBarWhenScrolling as I think by default it is true, but if you still see the search bar then you can set it true to hide it.
I faced the same issue as you and looks like such issue appears in iOS 13 only. In iOS 14 your solution works perfectly.
To make it work in iOS 13 you need to add
self.navigationItem.hidesSearchBarWhenScrolling = true
self.navigationController?.view.setNeedsLayout() // add this line
in viewDidAppear
It works for me in simulator iOS 13.7 I hope it work for you as well.

"Print" & "Cancel" disappeared from Printer Options in UIActivityViewController

The buttons are still there and function fine, however as you can see they are completely invisible. Adjusting font colors and navigation bar colors had no effect. I have been trying to resolve this for months and despite reading Apple's documentation, I am unable to even see where you would change what I assumed to be a system wide function.
So to help narrow down this issue I created a simple navigation controller with a print button. If I put these both on the Login storyboard (the first storyboard) it works perfectly fine. If I put it on Main.storyboard (the second storyboard) it doesn't work.
If I change my project settings to make Main.storyboard the first storyboard it works. Leading me to believe the issue is in my FirstViewController.
You can set the color of the print and cancel button
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UIToolbar.self]).tintColor = UIColor.green
After narrowing down the problem to the first view controller I discovered the tint was set to Clear Color (ie Alpha is 0). Fixing this resolved the problem in the rest of the app. I am surprised a setting in a view can propogate to the rest of the app and overwrite all of the other views in the process. Perhaps apple set the first view to determine the colors for system pop ups etc.

Getting Autolayout beneath the status bar

I have read multiple previous posts on Autolayout and the status bar behavior in iOS 7 and still do not know how to get my Autolay-ed out objects to be beneath the status bar.
I currently have
self.automaticallyAdjustsScrollViewInsets = YES;
self.edgesForExtendedLayout = UIRectEdgeNone;
and a search bar has a visual format applied like V:|-0-searchBar-|.
The search bar renders under the status bar like
as expected.
I have been unable to find a solution to get the search bar to start at the bottom edge of the status bar. How can this be done?
EDIT: I have looked at the top layout option, but I have a xib for my Custom View Controller. There is no top layout guide available. How can I support this setup? I would like to avoid checking the system version.
You need to use the topLayoutGuide.
Apple has a great guide on this issue: https://developer.apple.com/library/ios/qa/qa1797/_index.html
I was able to programmatically access the top guide by following this answer. I was using XIBs for my custom class and thus could not access the topLayoutGuide through the graphical interface builder as seen below.
Instead topLayoutGuide can be accessed through [self topLayoutGuide], where self is the UIViewController. Documentation link
if ([self respondsToSelector:#selector(topLayoutGuide)]) {
id topGuide = [self topLayoutGuide];
NSDictionaryOfVariableBindings(topGuide ...

UINavigationbar barTintColor not working in UISplitview Template

I am trying for hours to change the Navigationbar barTintValue in my App.
I am using the Master-Detail Template from Xcode using Swift and
I read a lots of questions here, but the answer was always to use
navigationController?.navigationBar.barTintColor = UIColor.redColor()
This works fine in AppDelegate, but I want to change the color in each DetailView depending on its content at runtime.
When i put this code into the Master or DetailViewController just nothing happens. I printed out the colors before and after and it does set the values, it just doesn't change.
Do I need to update the view or something?
Thanks for you help!
Maik
As always i just found the answer right after posting this.
I don't think its the solution, but its a workaround.
I change the color for the detailView in prepareForSegue, and change it back to default in the masterViews viewWillAppear.
I faced same problem.
I have found a solution.
navigationController?.navigationBar.backgroundColor = UIColor.redColor()

disable scrolling in a UITableView (iPhone SDK 3.0)

I'm trying to disable scrolling in a UITableView when editing a UITextField embedded in a UITableViewCell.
This is just to prevent the cell from being scrolled out of sight when edited (and also to avoid some related cell "Recycling" problems).
While googling around I've seen that somebody suggested the obvious:
tableView.scrollEnabled = NO:
or even
tableView.userInteractionEnabled = NO;
This does not work though (at least for me... iPhone SDK 3.0, tried on simulator)
I set these properties to NO, I even check by logging that the properties are set to NO, but the UITableView keeps on responding normally to touch events.
And it also happily scrolls.
I wouldn't be that worried if somebody on the net were not claiming that this actually works.
Am I missing something?
Or is the only alternative subclassing UITableView to make a functionality available in its superclass (UIScrollView) work again?
Did you try using
self.tableView.scrollEnabled = NO;?
I've often tried that code from the web didn't work, simply because of a lack of the prefix self. I just tried this out without a problem.
I don't know if this work when turning it on and off dynamically. It does at least work for permanent settings when initializing the object...
If you're using UITableViewController, you also have a tableView property, with no casting needed. This works for me:
self.tableView.scrollEnabled = NO;
Let me know if that works for you.
Did you try on storyboard unselect scrolling enabled?
I tried:
[(UIScrollView*)[self view] setScrollingEnabled:NO];
and it worked ([self view] is my view of the current view controller, i.e., a UITableView).
The thing is, I get a warning:
'UIScrollView' may not respond to '-setScrollingEnabled:'
In all honesty, the property is "scrollEnabled", but it works nonetheless with the aforementioned code!
So, the "right" way to do things, should be:
[(UIScrollView*)[self view] setScrollEnabled:NO];
Why it also works the other way, is confusing me...
None of these answers worked in my case. Table view kept scrolling ever though every scrollView was disabled.
Finally, I've found solution in here, claiming that UITableViewController does this "for me" whenever keyboard hides the UITextView being edit.
Solution is to inherit from UIViewController instead of UITableViewController and implement the required table functionality myself.
if you want to scroll only if its content is not visible then set:
yourTableview.alwaysBounceVertical = NO;
Here if your content is visible then your tableview will not scroll

Resources