Reputation: 23
I want to create an app which uses UISplitViewController. I am using xcode 6 + ios 8.1 SDk. I had created sample app which works fine on iOS 8 (iPhone 5 , IPhone 6+, iPad) but fails on iOS 7. Does any one help me to implement this funtionality with supporting both iOS 7 & iOS 8.(Am using Language Objective C)
Upvotes: 0
Views: 245
Reputation: 116
You actually can use UISplitViewController under iOS 7 (on iPhone or iPad), but there are a few tricks. First, I'm not sure if is possible programmatically but you should use a storyboard. Second, make sure you have Use Size Classes checkbox option enabled on the storyboard.
Lastly, there are also some issues where you may get called with a nav controller instead of the the split view controller. For example, in the default prepareForSeque method (provided by the default split controller project), I had to make the following #if 1 tweak:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSDate *object = self.objects[indexPath.row];
#if 1
DetailViewController *controller = nil;
if ([segue.destinationViewController isKindOfClass:[UINavigationController class]]) {
controller = (DetailViewController*)[segue.destinationViewController topViewController];
}
else if ([controller isKindOfClass:[UISplitViewController class]]) {
controller = segue.destinationViewController;
}
#else
DetailViewController *controller = (DetailViewController*)[[segue destinationViewController] topViewController];
#endif
[controller setDetailItem:object];
controller.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
controller.navigationItem.leftItemsSupplementBackButton = YES;
}
}
Upvotes: 1