Note: in iOS 8, Status bar hides itself automatically in landscape and comes back in portrait(iPhone only).
To show videos in my app, I am using XCDYouTubeKit, which is a light wrapper on MPMoviePlayerViewController.
I had to set "View controller-based status bar appearance" in info.plist file to "NO" in my app due to some functionality. The app works fine till you don't use XCDYouTubeKit(MPMoviePlayerViewController). After using XCDYouTubeKit the app loses the functionality specified in "Note" above means status bar starts showing up in landscape also.
You can download the demo project here.
https://www.dropbox.com/s/yp5pkvf9evsl8wb/XCDYouTubeKit%20Demo.zip?dl=0
To experience this thing you need to follow the following steps in XCDYouTubeKit demo:
set "View controller-based status bar appearance" in info.plist file
to "NO".
Open the app in iOS 8 and go to "Full Screen Player".
Change the Orientation to portrait to landscape or vice-versa. You will observe that the status bar hides in landscape but not in portrait.
Now tap on "Play Full Screen" button(Portrait mode) and let the view controller come up.
Dismiss the video by pressing "done" button( irrespective on orientation ).
Change the Orientation to portrait to landscape or vice-versa. You will observe that the status bar stays there all the time irrespective of the device orientation.
Please help!!!
Note too, Harsh, you can (controversially!) just use a category for that!
only once for the whole app. We do his every single time in high-volume production apps (in the objective-c era) with no problem, and I see it constantly in high-volume client projects. ... So ..
1) make a category called exactly UIViewController+HideStatusBar
#interface UIViewController (HideStatusBar)
#end
// the only practical approach for no-statusbar in iOS7,8+
#implementation UIViewController (HideStatusBar)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
-(BOOL)prefersStatusBarHidden {return YES;}
-(UIViewController *)childViewControllerForStatusBarHidden {return nil;}
#pragma clang diagnostic pop
#end
2) in your plist add
<key>UIStatusBarHidden~ipad</key>
<true/>
// that is needed if you're covering iPad; do it always for consistency
3) Do not set "Status bar is initially hidden" to "YES" in your plist.
4) Do not alter UIViewControllerBasedStatusBarAppearance.
Extended discussion.
I couldn't find the solution for the original problem. But I managed to achieve the ultimate goal i.e. status bar stopped showing in landscape for (iOS 8 && iPhone).
I was setting "View controller-based status bar appearance" to NO because I had to set the status style light through out the app.
But as setting "View controller-based status bar appearance" to NO was causing the main problem, I removed it, which resulted in status bar black through out the app but solved main problem.
Then I had to put the following code in all independent view controllers:
-(UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
and for those view controller which were contained in UINavigationController i took the reference from following question:
preferredStatusBarStyle isn't called
Related
Just started with Swift and would like to replicate some functionality present in the standard Apple 'Notes' app. Specifically the Expand button that appears in the Details View when on iPad in landscape mode.
i.e.
The closest I have come (as a simple quick solution) is to add the following into AppDelegate:
splitViewController.preferredDisplayMode = .primaryOverlay
However although this allows for toggling the Master View in landscape orientation (similar to the default portrait behaviour), it is done with the Master View as a popover/overlay. I however would prefer the behaviour present in the Notes app in that the Master View slides in/out (without overlaying the Detail View).
Edit: also interested in how to only show the corresponding button only in Landscape mode while on iPad.
Any help would be greatly appreciated! Thanks
splitViewController.preferredDisplayMode = .allVisible
This should do the trick. It makes the Master View slide in and out when toggling to fullscreen mode.
So I'm trying to run a new tabbed application in the iPhone simulator, but I keep getting a black screen after my app loading screen.
I've tried Reset Content and Settings and I've made sure that my storyboard is the main interface.
My app also doesn't appear in the iPhone simulator app pages
Black screen appear only when, you do not set any initial launching screen in the application, and thus it show black window screen. In your storyboard select "Tab Bar controller Scene" and check its attribute inspector and check if "is Initial View controller" field is selected or not.
Make sure you set your initial view correctly in Storyboard
I've read to many posts but I can't find a solution.
I've a tabbed application using storyboard. All the View Controllers of that Tabbed Application must show the content in portrait orientation, but there's only one viewcontroller (which is showing a video) that I want to be in landscape mode.
EXPLANATION OF THE STORYBOARD: TabBarController -> 4x Navigation controllers -> each navigation controller points to his ViewController -> one of these view controllers have an image, when I press that image, i've done a push to another view, the view that I want to have in landscape mode because I have there a UIWebView to show a video.
I'm unable to have all the app only in portrait orientation and the viewcontroller mentioned capable to rotate in landscape mode.
My app is also supporting iOS 5, so I know there are methods deprecated and I'm getting crazy.
I believe that in Summary > iPhone / iPod Deployment info > Supported Interface Orientations > there I've to check Portrait, Landscape left and right, and then via methods, enable or disable the rotations. I'm lost.
Can you help me?
I think you should be able to do this if you push to the view as a modal. Make sure your application's PList file (under Supporting Files folder) is set to support all orientations and then simply add the code to the modal view controller to display landscape with something like this.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Let me know if you have any luck.
As i worked out for my App i advise you to use this solution.By using some conditions in the shouldAutorotateToInterfaceOrientation method orientation type we can solve this.Just try with this link will help you.
https://stackoverflow.com/questions/12021185/ios-rotate-view-only-one-view-controllers-view/15403129#1540312
I´m making an app for a Zoo, and it is very simple, but because at fisrt I tried to make it with code and using xcode 3.2, but I had some problems so I started it with Xcode 4.3 and am trying it with the storyboards.
My question is, how could I put all the app in landscape mode? I mean I already set it in the infoplist: the initial interface orientation, and then in the .m file I changed the following:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationLandscapeRight;
}
But it doesn´t work. When I add a tabbarcontroller and link it all the views become portrait. The first one if I rotate it it does give me the landscape but all the others are always in portrait, so what can I do?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return interfaceOrientation==UIInterfaceOrientationLandscapeRight;
}
When you add tabbar controller on storyboard, in attribute inspector of tab bar you have orientation that is on inferred by default, change it to Landscape. But is better you set orientation from summary tab of project to Landscape Right. it lets your up come up on Right landscape.
In the 3.0 version of the iPod application (and maybe in previous versions too) when the iPod application is launched after a sync the UITabBarController appears with no tab selected...
iPhone iPod loading screen
Is there any way to accomplish the same behaviour? or is this just the Default.png displayed by the iPod app at startup?
This will work when your tab bar is already loaded:
self.tabBarController.selectedViewController = nil;
In applicationDidFinishLaunching, you'll have to use something like this:
[tabBarController performSelector:#selector(setViewController:) withObject:nil afterDelay:0];
I'm not sure it's the default.png, when I launch mine the loading screen appears to be all black - and you wouldn't expect a default.png to be able to have the tab bar elements when you are allowed to re-order them as you are in the iPod app.
Perhaps if you set the UITabBarController selectedVC to nil...
That doesn't look/feel like it is done with Default.png. Looking at the docs online (under selectedViewController), you can select a view controller that isn't shown in the tab bar but still in the viewControllers array, and may be this is how it's done in the iPod/music app. So essentially make a view controller for a tab that isn't selectable from the tab bar by the user, and select that view controller programatically.
Was able to get this working by making the selection on my tab bar controller from applicationDidBecomeActive with the following code:
- (void)applicationDidBecomeActive:(UIApplication *)application {
self.tabBarController.selectedViewController = splashScreenControllerThatHasNoTab;
}