Can't figure out how to get UpSide down orientation to work in iOS 8? - ios8

I added UIScreen bounds code in AppDelegate.m for iPhone 6 and now device orientation for iPhone 6 won't work for Portrait/ Upside Down. Upside Down is what's not working in simulator and devices.
Code in AppDelegate.m
CGSize iosScreenSize = [[UIScreen mainScreen] bounds].size;
if (iosScreenSize.height == 667) {
UIStoryboard *iPhone6 = [UIStoryboard storyboardWithName:#"iPhone6" bundle:nil];
UIViewController *initialViewController =[iPhone6 instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
}
When I included the above code the simulator and device for iPhone 6 doesn't detect Upside Down orientation. I also used nativeBounds and screenBounds, didn't work either for Upside Down orientation.
My code for device orientation...
-(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
I have no idea what to do to get AppDelegate code to let UpSide Down orientation be detected for iPhone 6.

OK, finally figured this one out.
Then realized someone posted the answer here: Setting device orientation in Swift iOS
Go down to DaRk-_-D0G's answer.
I had to subclass my tab bar controller just to override that method. Very obnoxious .

Related

Xcode - crash opening camara on ipad

My iphone app use camara to take photo.
Installing the app on ipad, the access to camara make the app crash.
Someone knows if any difference exists on use the picker controller between iphone and ipad?
Tx in advance
---EDIT---
he codeo that thaht call the camara I using is:
- (void) showCamera{
UIImagePickerController * imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing =YES;
[self presentViewController:imagePickerController animated:YES completion:nil];
}

PresentViewController With ModalPresentationStyle "UIModalPresentationFormSheet" IOS 8

I am not able to set frame to PesentViewController with ModalPresentationStyle UIModalPresentationFormSheet in IOS 8. Same code works perfect in IOS 7. For all other ModalPresentationStyle, i am able to set frame. I am doing migration work from IOS 7 to IOS 8. If it is a IOS 8 bug i need a reference to produce.
FirstViewController *saleNotApprovedController = [[FirstViewController alloc]init];
saleNotApprovedController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:saleNotApprovedController animated:YES completion:^{
saleNotApprovedController.view.superview.frame = CGRectMake(100, 200, 500, 500);
}];
I tried to set frame in viewWillLayoutSubviews For PesentViewController. This code works while loading the page but when we change the orientation PesentViewController align to centre automatically.
Please use preferredContentSize to set view's frame.

Presenting UIImagePickerController over modally presented view controller does not work correctly in iOS 8

I have presented UIImagePickerController from modally presented view controller. After clicking the image I get a black image instead of the clicked picture
I did something Like this.
//From ViewController1 I presented view controller2 with
- (IBAction)buttontappedToPresentViewController2:(id)sender
{
ViewController2* controller2 = [[ViewController2 alloc] initWithNibName:#"ViewController2" bundle:nil];
controller2.modalPresentationStyle = UIModalPresentationPageSheet;
[self controller2 animated:YES completion:nil];
}
//In ViewController2, I presented the UIIMagePickerController
- (IBAction)cameraButtonTapped:(id)sender
{
UIImagePickerController *cameraController = [[UIImagePickerController alloc] init];
cameraController.mediaTypes = #[(NSString *)kUTTypeImage,(NSString*)kUTTypeMovie];
cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:cameraController animated:YES completion:NULL];
}
After clicking the image you will get black screen instead of the captured image with retake and use photo options. If you select "Use Photo" option you get the correct image in callback.
Note: If you do not set UIModalPresentationStyle for viewController2, the code works fine.
Any idea what is going wrong here.
EDIT: I have used XCODE 5.1 and my target deployment is iOS 7. I am running the app on iOS8 device.

How to develop for multiple iOS devices, i.e. multiple storyboards?

I am currently developing an app for the iPhone 3GS. The deployment target is set to 5.1 and I have created a rich storyboard with lots of segues and scenes. Last night I had the idea that I wanted to make the app available for the iPad, iPhone 4, and iPhone 5. I decided to create a separate storyboard for the different screen sizes / resolutions. Now I am not sure if this is the best practice, as I have just recently started reading about springs and struts on SO, so I don't know much information about it, but for my sake, I just wanted to launch a different storyboard when the application finished launching. However this desired effect is not happening.
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// ViewControllerWelcome *viewControllerWelcome = (ViewControllerWelcome *)[[ViewControllerWelcome alloc]init];
// NSManagedObjectContext *context = (NSManagedObjectContext *) [self managedObjectContext];
// if (!context) {
// NSLog(#"\nCould not create *context for self");
// }
//[viewControllerWelcome setManagedObjectContext:context];
// Do I need to declare my view controllers here?
// Pass the managed object context to the view controller.
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480)
{
// Instantiate a new storyboard object using the storyboard file named iPhoneLegacy
UIStoryboard *iPhoneLegacy = [UIStoryboard storyboardWithName:#"iPhoneLegacy" bundle:nil];
// Instantiate the initial view controller object from the storyboard
UIViewController *ViewControllerWelcome = [iPhoneLegacy instantiateInitialViewController];
// Instantiate a UIWindow object and initialize it with the screen size of the iOS device
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Set the initial view controller to be the root view controller of the window object
self.window.rootViewController = ViewControllerWelcome;
// set the window object to be the key window and show it
[self.window makeKeyAndVisible];
}
if (iOSDeviceScreenSize.height == 968)
{
// Instantiate a new storyboard object using the storyboard file named iPhone4
UIStoryboard *iPhone4 = [UIStoryboard storyboardWithName:#"iPhone4" bundle:nil];
UIViewController *ViewControllerWelcome = [iPhone4 instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = ViewControllerWelcome;
[self.window makeKeyAndVisible];
}
// iPhone 5 1136 x 640
// iPad Legacy 1024 x 768
return YES;
}
When I try testing to see if the different storyboard file are loading in the Simulator, Simulator just loads the iPhoneLegacy storyboard.
Does this code only work for the physical devices, and do I need separate code for the Simulator?
Fist of all, DELETE YOUR EXTRA STORYBOARDS! You only need one for the iPhone and one for the iPad.
There is a simple way to make a single storyboard for all iPhone/iPod Touch sizes.
Keep only ONE storyboard for the iPhone screen size (including iPhone 5).
Make a #2x file for all of your images.
To switch between 3.5 and 4 inch size, Apple provides a button in the bottom right that looks like a rectangle with arrows pointing in or out - that button will switch between the 3.5 and 4 inch screen sizes.
That's it! No code is actually needed to make a single storyboard for each iPhone/iPod Touch.
For the iPad, you are going to need to create a new storyboard that is made for the iPad and you are going to need to update your UI code to make sure it's compatible with both iPhone and iPad screen sizes. Again, make sure to make #2x image sizes for the iPad as well.

MapKit MapView Annotations overlapping on a real device

I have the problem depicted in the image when testing my app on a real device (iPhone 3G, 3.1.3).
It is fine in the simulator (xcode 3 with ios 4.1 sdk). sorry, can't post images yet, this is my first question here.
http://i.stack.imgur.com/Ct4on.jpg
I have the following code in the implementation of the annotation:
- (id)initWithLocation:(CLLocationCoordinate2D)coord {
self = [super init];
if (self) {
coordinate = coord;
}
return self;
}
And this is part of the header file:
#interface MyAnnotation : NSObject <MKAnnotation>
And this is where I create a new one (inside a loop):
MyAnnotation *theAnnotation = [[MyAnnotation alloc] initWithLocation:theCoordinate];
theAnnotation.title = [single objectForKey:#"address"];
theAnnotation.objID = [single objectForKey:#"id"];
[self.mapView addAnnotation:theAnnotation];
[theAnnotation release];
Any ideas about this? I don't know what to look :/
You could try to bring the (annotation)view to the front, when tapping on it.
So, when someone taps on an annotation, you should call [[self superview] bringSubviewToFront:self];
Best,
Christian

Resources