UIMediaPickerController under iOS 8 - ios

I've run into an issue with the media picker on iOS 8.
I have an iPad application, landscape mode supported only.
The following code works just fine under iOS 6 and iOS 7, but on iOS 8, it presents the media picker in landscape mode, but a vertical gradient line appears along the right side of the picker, where the portrait version would have its right edge. The picker works fine also to the right of this line, but I cannot figure out, how to make this gradient go away.
- (void) viewDidAppear:(BOOL)animated
{
MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
[self presentViewController:mediaPicker animated:YES completion:^{
}];
}
I'd appreciate your expert help ;

In my case the solution was changing the Orientation in the Deployment info. I had to uncheck the "Landscape" box. Of course now the orientation is not fixed but at least the "black gradient" problem was solved.

Related

iPad App is not launced in landscape mode and getting black screen portion when launching in landscape mode

I have a universal iOS app and currently I am developing it for iPad.
When I am launching the app in the portrait mode app launches fine. But when I launch in landscape mode, portion of the screen becomes back and the app is not launched in landscape mode. I have used
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll; }
- (BOOL)shouldAutorotate {
return YES;}
but the app is not launching in landsape mode and having a black screen portion. I have attached a screen shot as well.. What is the problem here and how to get rid of this?
Try this, write this in ViewDidLoad, We need to set the insets for self.view
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout=UIRectEdgeNone;
}
Since your view is rotated correctly (the text is upright) you can assume that this problem is not a rotation problem but instead a problem with your layout code/interface builder.
To solve this make sure you pinned your content view to all edges of his superview
I had the same problem when iOS8 comes out. With iOS7 all worked fine. After spending a lot of time try to solving i just find that replacing the "launch xib" with a storyboard fix my problem.
So try to add a storyboard, put your actual initial xib into and restart. Don't forget to specify the inizial storyboard into your project's info.
NB you probably have this problem on iPhone6+ as well because it is capable of running springboard in landscape.
I rarely (pretty much never) use storyboards or nibs, so I've had this problem since iOs7 in applications which support rotation. I set up my viewControllers in loadView or viewDidLoad and at that point the viewController does not know the interfaceOrientation. Because I usually handle rotation programatically as well I just do something like this in viewWillAppearAnimated:
{
BOOL landscape = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication]statusBarOrientation]);
BOOL ios8 = NSClassFromString(#"UIPopoverPresentationController")!=NULL;
if (landscape&&ios8) {
[self willRotateToInterfaceOrientation:[[UIApplication sharedApplication]statusBarOrientation] duration:0.0];
}
}
Just solved similar problem by setting UIMainStoryboardFile for my app (although this has no side effects on my app as I am setting my ViewControllers in code). So setting main storyboard file has fixed this for iOS 8 through 10.
So set both launch screen and your main interface storyboards.
Setting NSMainNibFile have not fixed that problem for me. Only storyboards.
Main storyboard should contain at least initial view controller that could be empty.
In the appDelegate, set:
[self.window setFrame:[[UIScreen mainScreen] bounds]];
in the didFinishLaunchingWithOptions

iOS 8 Orientation Issues : Keyboard ends up in incorrect position

I have a universal project for iOS that was created in xCode 5 that I am trying to port to xCode 6. Everything seems to have been fine since I am not using LaunchScreen and iPhone 6 and 6 Plus scale the application to their resolutions.
The problem occurs when device changes its orientation.
Scenario:
It only occurs on iPhone 6 and 6 Plus.
Open Login screen with username and password fields. Rotate the device to Landscape, and tap username or password field. The keyboard appears in the middle of the screen with half cut. Rotating back to portrait hides the keyboard altogether and it no longer appears on screen no matter which field you tap on.
To get the keyboard back, rotate back to Landscape, tap on a field rotate device to opposite Landscape (don't let it go in Portrait). The keyboard suddenly becomes normal and acts fine.
I got the same problem, and that's because your app is launched in scaled mode.
It seems that Apple didn't go the full blown way to handle landscape in this scaled mode.
The solution is to switch to non-scaled mode for the iPhone 6-6Plus, using the trick specified here: How to enable native resolution for apps on iPhone 6 and 6 Plus?
Note that this will likely break a lot of your screens in the process.. but there's no other solution.
I have faced this issue with scalable mode of the app. Though supporting non-scalble mode (by adding iPhone 6 & 6+ launch images to xcassets) solves this problem, it was not permissible in my case as screens had static layout for each orientation.
I could solve this problem by avoiding the incidents of changing the root view controller of the window. Instead, the new view controllers have been added (with balancing removal) as subview (and hence childViewController) to the existing root view controller.
Everything is ok on iOS6/7, But not iOS8.
The orientation of the keyboard on iOS 8 is not the same as status bar.
If your application runs only portrait mode you can stop generating orientation notifications;
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
I have faced this issue, and after some research I found some stuff, that caused such bug.
In my AppDelegate I changed window rootViewController to show different ViewControllers depends of authorization status
if (!auth)
{
self.window.rootViewController = [[AuthViewController alloc] init];
} else {
self.window.rootViewController = [[DataViewController alloc] init];
}
I removed this and move controller select logic to NavigationViewController
if (!auth)
{
self.viewControllers = #[[[AuthViewController alloc] init]];
} else {
self.viewControllers = #[[[DataViewController alloc] init]];
}
and make this NavigationViewController as Storyboard initial view controller.
Hope it helps!

iPhone6 (no display zoom mode) UIMenuController truncated

I have a problem with the UIMenuController on my iPhone 6 when I use the standard display mode and device is in landscape mode. On iPhone 6 Plus the problem is in both modes. Maybe it's depends on screen resolution.
In that case, the UIMenuController will be truncated left and/or right. It seems that the UIMenuController can have maximum bounds as if the phone is in portrait mode.
See UIMenuController truncated (iPhone6 landscape schematic):
http://imageshack.com/a/img631/8470/ozlaGe.jpg "iPhone6 landscape"
For me it seems like an iOS8+iPhone 6 bug. The code didn't change for a long time and worked.
In zoomed display mode, UIMenuController will be displayed correctly like on all other iPhones/iPads incl. iOS7.
... define UIMenuItems....
[self becomeFirstResponder]; // canBecomeFirstResponder returns YES;
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:items];
.. define frame...
[menu setTargetRect:frame inView:self];
[menu setMenuVisible:YES animated:YES];
Fixed: see comment from Iliya Barenboim
The reason is that you didn't have launch images for iPhone 6 and iPhone 6+.
One other thing that I ran into when adding the launch images, is that there is a bug when doing this with an asset catalog. I added static launch images to my project and manually edited my info.plist as described here: https://stackoverflow.com/a/25960203/378179.
It's not a compilation issue. I ran the same code on the iPhone 5 iOS 7.1 simulator in Xcode 6.1, and the problem doesn't appear -- only when you run with the iPhone 6 / iOS 8 simulators (and, of course, on the iPhone 6 device itself). So it's a problem with the iOS 8[.1] runtime.

Hiding the Status Bar for an iPhone app running on iPad

My iPhone app requires that the status bar be hidden at all times. This is generally easy to do, and it works if I only run the app on an iPhone. However, if I run the app on an iPad, the status bar still appears at the top of the content. So, how do I make sure the status bar is hidden no matter device my iPhone-only app is running on? I'm currently doing the following in my code:
Calling this method for each view controller(I actually created a category on UIViewController that implements this automatically for any VC, but it's basically the same as writing it in each vc file):
-(BOOL)prefersStatusBarHidden{
return YES;
}
I also set "status bar is initially hidden" to YES and "View controller-based status bar appearance" to NO in Info.plist. I've also tried detecting which device is being used and calling
[UIApplication sharedApplication]setSetStatusBarHidden:YES]
in the AppDelegate, but no luck there either. So, I believe I've tried just about everything that one would think to try.
It seems this was introduced into iOS 7.1 and affects non-retina iPads running iPhone applications with retina graphics.
No solution for developers. I think Apple will have to patch this one...
Problem devices:
iPad 2
iPad Mini (non-retina).
Problem does not exist in iOS 7.0 and status bar issues can be fixed for 7.0 with the other solutions posted.
Update for September 2014 - iOS 8:
This bug is fixed for iOS 8!!!!!
Add this code.
- (BOOL)prefersStatusBarHidden{
return YES;}
Add an property in YourViewController as
#property BOOL statusBarHidden;
and then in ViewDidLoad add the following lines of code
[self prefersStatusBarHidden];
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
self.statusBarHidden = YES;
Then add an method in YourViewController
- (BOOL)prefersStatusBarHidden{
return YES;}
and also don't forgot to add the #import <UIKit/UIKit.h> in your code it works great for IOS6.1 & 7.0 :)

UITapGestureRecognizer fails on iPad in landscape orientation

I am working on a single-view app that has a UITapGestureRecognizer. I noticed that when I tried it on my iPad, the taps weren't being recognized. After I zoomed the app with the 1x/2x button, the taps started working. What am I doing wrong?
I have narrowed this down to a very small sample. I started with the XCode "Single View Application", and the following is the viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
info = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 20)];
[self.view addSubview:info];
tapper = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleTap:)];
[self.view addGestureRecognizer:tapper];
}
Here is what I know so far:
Works on iPhone-sized screens.
Works on iPad in portrait orientation.
Fails on iPad in landscape orientation, until the view is zoomed with 1x/2x, then it starts working (and continues working after zooming back to the original zoom level).
Exhibits the same behaviour with the iPad simulator.
The complete code is in a GitHub repository so you can view the whole thing or try it. XCode 4.5.1, iPad retina, iOS 6.0.1.
I have found that if I remove all of the entries under "Supported interface orientation" in the app's plist, this problem goes away. Or if you check the "Hide during application launch" option for the "Status Bar" settings on the Summary screen of the Target settings, this also fixes it:
There's no logical reason that I can see that either of these options should fix this bug, but they both do.
Obviously, if you do play around with the "Supported interface orientation" option, in iOS 6, you can still programmatically control the permitted orientations via supportedInterfaceOrientations (shouldAutorotateToInterfaceOrientation: in iOS 5).

Resources