UITableViewController won't do UIDeviceOrientationPortraitUpsideDown orientation - iphone

i got a problem on my UITableViewController it wont do UIDeviceOrientationPortraitUpsideDown orientation. I already set on shouldAutorotateToInterfaceOrientation function allowing the two portrait orientations.
Here's my code on implementing my UITableViewController
UITableViewController *controller = [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];
controller.tableView.delegate = self;
controller.tableView.dataSource = self;
controller.tableView.scrollEnabled = NO;
thanks

The most likely explanation is that your app itself won't support upside-down (the Apple human interface guidelines suggest that iPhone apps should not be rotated upside-down.) You can modify this in your project settings within Xcode.
If that's not it, can you post your code for shouldAutorotateToInterfaceOrientation?

Related

show specific viewcontroller only in landscape, but support iPad multitasking features

I´m developing an application for iPad & iPhone.
The App is supporting on iPad all Orientations, because of Multitaskingfeatures.
On iPhone my App is supporting only Portrait.
For one Specific ViewController I want on both devices to support only Landscape.
On the iPhone was using following solution:
I disabled all orientations in .plist and worked with two Navigationcontroller.
One for landscape and one for Portrait.
pushing my VC for Landscape:
LandscapeNavigationController *navController = [[LandscapeNavigationController alloc] init];
[UIApplication sharedApplication].keyWindow.rootViewController = navController;
[navController pushViewController:[Logic sharedInstance].myLandscapeViewController animated:YES];
Code in my NavigationController:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
return YES;
}
My Problem is that I cant handle the orientation on iPad in code because I have to enable all Orientations in .plist to support Multitasking.
So the delegatemethods supportedInterfaceOrientations in my Navigationcontroller wont be called.
Has anybody an idea to support multitasking on iPad AND allow one specific ViewController only one supportetInterfaceOrientation?

upgrading iPhone app to universal and now using splitview

I have an iPhone app that works and is getting used. I now want to upgrade this application to a Universal app. Taking that into consideration I've already made changes, like creating another MainWindow.xib for the iPad, which i've gotten to work. I've pretty much got the whole iPhone App working for the iPad. The next step I needed to take was to convert my Events Calendar to be a splitview. As far as I can tell, I'm don't need to change any of the logic in the two controllers I already have (CalendarViewController and CalendarDetailViewController).
That being said, what is the best way to make them work on a splitview? Is it possible to have the splitview use these two controllers (since a splitview has two controllers by default, a TableViewController and a ViewController)? Would I then need to create another appDelegate or something to pass all the right information back to the MainWindow.xib? Or am I going to need to create a new SplitViewController? and if so, how would I then combine all the logic from my two Calendar Controllers?
Any help would be greatly appreciated!!
Assuming you are using StoryBoard: drag a SplitViewController into the iPad StoryBoard. Also be sure your two desired UIViewControllers are in there. Control-click on the SplitViewController and drag over to each UIViewController and select you how want it set.
I know it's a bit late to answer this question but if someone needs...
You don´t need another appDelegate, you just need to check (in appDelegate) whether your device is an iPad, and then set an array of view Controllers with the MasterVC and the DetailVC. Otherwise you will set your rootViewController as you are doing now in the iPhone app.
It would be something similar to that:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[...]
YourMasterVC *mvc =
[[YourMasterVC alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *masterNav =
[[UINavigationController alloc] initWithRootViewController:mvc];
YourDetailVC *dvc = [[YourDetailVC alloc] init];
cvc.detailViewController = dvc;
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
// On iPad
UINavigationController *detailNav =
[[UINavigationController alloc] initWithRootViewController:dvc];
UISplitViewController *svc = [[UISplitViewController alloc] init];
svc.delegate = wvc;
svc.viewControllers = #[masterNav, detailNav];
self.window.rootViewController = svc;
} else {
// On iPhone
self.window.rootViewController = masterNav;
}
[...]
}

App doesn't rotate on iPhone Simulator

I'm wanting to test out my app with the iPhone 5 resolution, so I'm using the simulator. My app has Portrait and 2 landscape orientations in Supported Device Orientations, and the viewControllers which allow rotation have shouldAutorotateToInterfaceOrientation set to YES. Yet when I rotate the device in the simulator, it doesn't rotate as it does on the device. Right now i'm just using the standard iPhone 4 simulator.
Edit: This is the code I have for setting my VC.
UIViewController *vc = [[UIViewController alloc] init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
[self.window addSubview:self.navigationController.view];
self.loadingWood = [[UIImageView alloc] init];
[vc.view addSubview:self.loadingWood];
And then shortly after:
self.timeline = [[JTimelineViewController alloc] init];
[self.navigationController setViewControllers:[NSArray arrayWithObject:self.timeline]];
This is necessary for visuals when the app starts up.
EDIT 2:
I now have this working. The problem I now face is that despite one of my viewControllers stating this, it still rotates upon any rotation on the iPhone Simulator:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
EDIT 3: My phone is running iOS5. The simulator is running iOS6. This is a possible reason. Removing Landscape Left and Landscape Right as supported orientations means no simulator rotation at all, but my iOS5 iPhone 4 continues to rotate as normal.
Make sure that you're setting the root view controller, as in:
self.window.rootViewController = self.navigationController;
I had to deal with something similar in the past. What's going in is that only the main view controller of the application receives the rotation notifications and delegate calls. There are some exceptions, like the UINavigationController, that passes down those events to their current view controller.
So, for example, if your AppDelegate class loads a view controller and that view controller pushes a second view controller, that second view controller will not receive the rotation notifications.
I recommend you use a UINavigationController to push your UIViewControllers onto the display, since UINavigationController passes down the rotation delegate calls and notifications.
EDIT
In Xcode's preference, under the Download tab, you have the option of downloading previous simulators, iOS 5 and iOS 5.1. Download those and set your target iOS version to 5.0 (or 5.1) and select the correct simulator from the device list. See if you get the same problem as with the iOS 6 simulator. If you get that, than there's definitely a difference between iOS 5 and iOS 6's way of handling UINavs.
Also, using the difference between setViewControllers and pushViewController is that pushViewController adds the view controller as a child of the parent view controller, which makes it respond to the delegate calls, including rotation. Since iOS 5, every UIViewController now has a method called addChildViewController that gives that functionality to the UIViewController class.

UIImagePicker can't perform full-screen transition on iOS 3.1.3

I am modifying my iphone app to make it backward compatible with iOS 3.1.3. I allow the user to load images from the photo library. I present the image picker with the following code:
UIImagePickerController* content = [[UIImagePickerController alloc] init];
content.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
content.delegate = self;
[self presentModalViewController:content animated:YES];
[content release];
This works correctly on ios 4.0+. However, on ios 3.1.3, the image picker never appears, and I get the following warning:
Can't perform full-screen transition. The fromViewController's view must be
within a view that occupies the full screen.
The fromViewController in this case is the visible view controller within a navigation controller. The navigation controller is set up in the appDelegate didFinishLaunchingWithOptions using the following code segment:
MyViewController* root = [[MyViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:root];
aNavigationController.delegate = self;
[window addSubview:aNavigationController.view];
Prior to attempting to load the image picker, another view controller is presented in the navigation controller. Therefore, at the time the image picker is loaded, two view controllers are in the navigation stack.
Based on another post, I have tried using the root view controller and the navigation controller as the fromViewController (the controller presenting the image picker). The behavior is the same.
I'm wondering if the problem has anything to do with the fact that the navigation controller's modalPresentationStyle cannot be set in iOS 3.1.3. For iOS 3.2+, I set the presentation style to UIModalPresentationFullScreen. I believe this is the default for previous iOS's. However, I'm suspicious simply because the warning I'm getting concerns full-screen views.
Can anyone provide any other suggestions? I have not been able to find any Apple documentation that addresses changes to UIImagePicker or UINavigationController from ios 3.x to 4.0.
Thanks in advance!
What I usually do when the view controller is inside a navigation controller is:
imagePicker = [[UIImagePickerController alloc]init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
[self.navigationController presentModalViewController:imagePicker animated:YES];
Hope it works for you!

How to switch between different classes in an universal iPhone / iPad app?

I have a special class that manages gestures and other things. It is strongly targeted towards iPhone. On the iPad, I need a 90% different behavior of that class, so I want to split MyController into MyController_iPhone and MyController_iPad.
How would I alloc-init the appropriate class depending on if it's the iPad or iPhone?
You can do something along the following lines:
MyController *controller = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
controller = [[MyController_iPad alloc] init];
} else {
controller = [[MyController_iPhone alloc] init];
}
You might want to subclass the controller for, say, the iPad. When you push/present it, check to see which platform you're on, and if you're on iPad, present the iPad subclass, with the modified behavior. You can use the UI_USER_INTERFACE_IDIOM() macro determine which device you're on.