How to hide the StatusBar in iOS13? - objective-c

I want to customize a toast view which needs to hide the status bar. Before iOS 13, I get the status bar by .
But in iOS 13 it will crash. So is there some ways to get the status bar in iOS 13?
Or does anybody know other ways to solve my demand.

-(BOOL)prefersStatusBarHidden {
return true;
}
Use this method.

Add this in info.plist file (open it in source mode):
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

If you want to hide/show status bar on the different view controllers for iOS 13 then you need to do this :
Add View controller-base status bar appearance option in your
Info.plist and set it to YES
Override var prefersStatusBarHidden: Bool in each View Controller
where you want to have the status bar shown/hidden
Refer this answer for more information in a detail.

Try this :
UIApplication.sharedApplication.statusBarHidden = true;

Related

iOS Navigation Bar Prefers Large Titles Scroll Behaviour

In iOS 11 the system apps all compress the navigation bar as you scroll down if you enable prefersLargeTitles:
I can't figure out how to implement this in my own apps though, the bar stays the same by default:
The only thing I can see is Hide Bars On Swipe, but that hides the whole bar rather than compressing it:
This is just an empty project created in Xcode 9 beta and with a new storyboard added.
What do I need to do to get the same behaviour as the system apps?
Don't set anything regarding Large Titles in Interface Builder / Storyboard, only in code. That worked for me.
So in the navigation bar in storyboards, Prefers Large Titles unchecked.
In your view controller:
self.navigationController?.navigationBar.prefersLargeTitles = true
It seems like this issue is happening to people for different reasons. None of the above answers helped me, but here's what DID work...
I deconstructed my app to find the cause, which was the view hierarchy in the storyboard. It appears that the UITableView view HAS to the the first view in your view controller. I had a UITableView with two UIImageViews behind it and that's what was causing the issue. Once I removed those UIImageViews everything worked correctly.
My fix: I ended up creating a UIView in code, adding my two image views to that, THEN adding that UIView to the UITableview.backgroundView.
Hope this helps someone.
If you have to target older iOS versions, you’ll also have to wrap the assignment in an availability check:
if #available(iOS 11, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
}
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = true
navigationController?.navigationBar.topItem?.title = "Hello"
navigationController?.navigationItem.largeTitleDisplayMode = .automatic
let attributes = [
NSAttributedStringKey.foregroundColor : UIColor.red,
]
navigationController?.navigationBar.largeTitleTextAttributes = attributes
} else {
// Fallback on earlier versions
}
http://iosrevisited.blogspot.in/2017/09/navigation-bar-with-large-titles-and.html

Appearance of NavigationBar

This is my very first question to the helpful group of stackoverflow.com
Please bear with me if question framing is cumbersome!!
I have a collectionView(in a ViewController),embedded in a NavigationViewController.
I have used didSelectItemAtIndexPath for each of the collectionView cells, linking them to different viewControllers,say VC1,VC2 etc
I have hidden the Navigation bar, in the ViewController containing the collectionView, using the code
self.navigationController?.navigationBar.hidden = true
In each of VC1,Vc2....., I have tried to unhide the navigationBar using the code,
self.navigationController?.navigationBar.hidden = False
During simulation, using xCode, the navigation bar appears only in VC1, but not in VC2,VC3....
From the details you provided it is hard to guess what is exactly the issue.
The navigation controller will remember its status, as long as you use push segues, it should stay hidden, unless you set it to show again. You can set it to be hidden before you perform the transition, say in didSelectItemAtIndexPath.
To hide the navigation controller, you can use:
navigationController?.setNavigationBarHidden(true, animated: true)
and to show it
navigationController?.setNavigationBarHidden(false, animated: true)

tvOS navigating through ui elements

I am developing for tvOS at the moment and I have added a UISegmentedControl, this gets focused automatically by the tvOS focus engine. When I added a UIButton, this became the first focused item.
How I do go about setting the first focused item and being able to navigate between them?
Add a read only preferredFocusedView property to your view controller that returns the view you would like to start focused:
override weak var preferredFocusedView: UIView? {
get {
return segmentedControl
}
}

how to click on action bar menu items in test app that having only apk using robotium

I am testing APK file. I dont have source code. I need to click on the action bar menu item
I have tried solo.clickonActionbaritems option and it did not work. Please help me. Many thanks!
I guess you want to click on Android Menu button:
Find your keycode here
solo.sendKey(KeyEvent.KEYCODE_MENU);
Also I highly recommend to use Hierarchy viewer in DDMS to find id of required button.
View requiredButton = getViewById(id.reqired_button_id);
solo.clickOnView(requiredButton);
// Method returns view
protected View getViewById(int id) {
View view = solo.getView(id);
assertNotNull("View is null", view);
assertTrue("View is not shown", view.isShown());
return view;
}
Also you can use clickOnText.

How can I interact with "iPad keyboard hiding button" programmatically?

There is a button at bottom right of iPad keyboard which is to hide the keypad.
How can I interact with it programmatically? (get the button then send UIControlEventTouchUpInside to it).
Does anyone know this?
[Edit]
In my case, the keyboard is shown on a modal view.
Overriding disablesAutomaticKeyboardDismissal to return NO as below allows you to dismiss the keyboard when you resignFirstResponder, even when your UITextView is on a modal view. You should put this code to your view controller, from which you initiate the keyboard:
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
Source: https://stackoverflow.com/a/6268520
In general, you would send the resignFirsResponder message to the active input view.
Something like this? I can't remember where I found this code but I used it to toggle the on-screen keyboard because it would be hidden by default if a bluetooth one was connected.
- (void) toggleKeyboard(UIKeyboardImpl * keyImpl){
if (UIKeyboardAutomaticIsOnScreen()) {
UIKeyboardOrderOutAutomatic();
} else {
UIKeyboardOrderInAutomatic();
}
Edit
I found where I got this code from. It works fine but the catch is that you need to import the private framework GraphicsServices, which would most likely get your app rejected from the App store.