I have added SwiftUI views in my existing swift project.
I have the following flow in the project
FirstViewController --NavigationPush -> SwiftUIView1 -NavigationLink->
SwiftUIView2 - NavigationLink-> SwiftUIView3 - NavigationLink
(UIViewRepresentable) -> SecondViewController.
till SwiftUIView3 everything works as expected. while pushing from SwiftUIView3 -> SecondViewController, even though I'm setting the navigation property isHidden = false,
the navigationBar appears in the controller for a fraction of sec and disappears. I have tried to unhide navigation in all the controller life cycle methods. But nothing happens. Please let me know your suggestion to resolve this.
FYI, below code, I used SwiftUI to hide the navigation bar.
Code Block
.navigationBarTitle("") // This should be empty.
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
I have a button in one of view controller of tab bar controller. All set up in storyboard. I registered action method like this
- (IBAction)buttonPressed:(id)sender {
NSLog(#"Button pressed");
}
The thing is that once I make left and top constraints (to force it stay in the right upper corner) touch up inside event stops working after I change rotation. So just open app in portrait mode - method is working. Change to landscape and I cannot tap button suddenly.
I've recreated problem in this easy example project.
Many thanks.
Just put the following code in you TabBarViewController class.
- (void)viewDidLayoutSubviews
{
// fix for iOS7 bug in UITabBarController
self.selectedViewController.view.superview.frame = self.view.bounds;
}
Recently I noticed same bug in my application. First I tried Slavco Petkovski method. But this caused me another bug with rotating and getting right bounds and frame, so I kept searching.
I found another solution for this problem, mainly setting autoresizing mask of view controller's view in xib. But since arrows in inspector in my Xcode (version 5.0.1) are inactive and you can't set them, you have to open xib file in text editor find autoresizingMask property for main view and change it like this:
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
EDIT:
Alternatively you can do this in your view controller's code - same result as in changes in xcode:
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
I'm creating an application and I want the status bar hidden. When I test the app, the status bar is hidden whilst the splash screen is shown, but once the app is fully loaded, the status bar reappears.
I'm using Xcode 5 and iOS 7, and have tried disabling the status bar programatically
([[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];),
in the info.plist file, and using the attributes inspector on the .xib file. Nothing appears to work.
Any ideas?
Try adding the following method to your app's root view controller:
- (BOOL)prefersStatusBarHidden
{
return YES;
}
You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".
This will enable you to set the status bar to hidden mode. This sets it to a global unlike other provided answers.
UPDATE: If you want that the status bar would be hidden on splash screen don't forget to mark "Hide during application launch" on target status bar options.
Also, you can add "Status bar is initially hidden" to "YES" on the plist if you don't want to do it with code inside the app.
The code you posted works for iOS 6.1 and below. For iOS 7, Apple has made new methods available to directly control the status bar for each view. Turning off this option in your Info.plist will enable you to hide the status bar, at least for the current Developer Preview (4).
For reference, please take a look at the iOS 7 transition guide that's available on Apple's developer portal.
well I try hide the status bar in all my app and in the "app"-info.plist and I add two rows in the dictionary "Information Property List" I add "View controller-based status bar appearance" set NO and in "Status bar is initially hidden"set YES and for me works n_n'
However, if you use UIImagePicker, the status bar appears again.
In that case, you should hide the status bar as below,
- (void)imagePickerController:(UIImagePickerController *)aPicker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// for iOS7
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
After some long searching, I finally found a very simple solution which also takes care of the UIImagePickerController problem.
As mentioned in the other answers, set your status bar hidden in your AppDelegate didFinishLaunching, and set the "View controller-based status bar appearance" to NO.
Then, in your AppDelegate:
- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame
{
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
et voila - your Status Bar will remain hidden even when the UIImagePickerController is foremost.
This is better than 'rehiding' it every time you present a UIImagePickerController as it remains hidden throughout the app.
To hide the status bar on a particular UIViewController, simply add this:
-(BOOL)prefersStatusBarHidden
{
return YES;
}
Hope this helps !
You can hide from the project summary. there is a checkbox hide during launch.
See the snapshot
I found this solution for me. It works like a charm.
Write this code on your viewcontroller which you wanted to use UIImagePickerController on.
- (void)viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
In addition to the answer from alones above, make sure to implement the imagePickerControllerDidCancel method and add the same code there too.
I was having issues with UIImagePicker as well. Similar to Alones answer, my solution was the following. I added this line or code:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
to this function:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
I haven't tested this with iOS 6 or older but it works great in iOS 7.
Swift Solution
just add this to your view controllers:
override func prefersStatusBarHidden() -> Bool {
return true
}
I am using Xcode 6, this solution works on iOS 7 and 8 for me:
First, Set the "View controller-based status bar appearance" to NO in plist file.
Second, in AppDelegate, add this:
- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame
{
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
My problem was that I used view controller containment. Only the top most view controller, which is embedded into a navigation controller for example, can hide or show the status bar.
I am building an iOS app in Rubymotion. I want to create a custom tabBar so I need
to use a real tabBar but hide it. How can I hide the tabBar in Rubymotion?
To hide the tab bar you can use hidesBottomBarWhenPushed.
The Objective C is:
MyController *myController = [[MyController alloc]init];
myController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myController animated:YES];
[myController release];
Therefore the RubyMotion Code is
#my_controller = MyController.alloc.init
#my_controller.hidesBottomBarWhenPushed = true
self.navigationController.pushViewController(#my_controller, animated:true)
I hope this helps. If you'd like to see more references to tab bars please check:
https://github.com/IconoclastLabs/rubymotion_cookbook/tree/master/ch_2/12_tabbars
Or if you'd like to see basics of navigation controller please check
https://github.com/IconoclastLabs/rubymotion_cookbook/tree/master/ch_2/11_navbarbuttons
I hope this helps!
In my project the tabs which are not under more section are properly responding to orientation but the tabs present under the more section are not responding.
For example if I am having two tabs names tab1 and tab2 under more section and if I am putting break point at the "shouldAutorotateToInterfaceOrientation" method of each tab.After that when if I am selecting tab1 from more section and tries to rotate it but the "shouldAutorotateToInterfaceOrientation" of the tab2 gets called.The delagate method of the tab which I am selecting is not getting called.I am working on XCode Ver 4.3.2.
Can someone please help me in solving this problem..
Thanks in advance,
Prajnaranjan Das
Please write followings code of all the root view controller of tab bar controller.
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return yes;
}
i face the same prblm as you facing now...
i was Return YES (shouldAutorotateToInterfaceOrientation Function) to all the view Controller classes inside tababarcontroller and my problem solved..
try to do this...might be you also get success
I used this method for orientation. Its working properly.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
}
There are several other methods which may help you in orientation such as:
• willRotateToInterfaceOrientation
• didRotateFromInterfaceOrientation
• willAnimateFirstHalfOfRotationToInterfaceOrientation
• willAnimateSecondHalfOfRotationFromInterfaceOrientation