Open UISplitViewController to Master View rather than Detail

Swift UISplitViewController display master view above detail in portrait orientation is not about showing the Master view, it is about presenting the Detail view in full width, underneath the Master view. UISplitViewController in portrait on iPhone shows detail VC instead of master is about the principle of the collapse mechanism. This present answer addresses: Master … Read more

Change the width of Master in UISplitViewController

If you subclass UISplitViewController, you can implement -viewDidLayoutSubviews and adjust the width there. This is clean, no hacks or private APIs, and works even with rotation. – (void)viewDidLayoutSubviews { const CGFloat kMasterViewWidth = 240.0; UIViewController *masterViewController = [self.viewControllers objectAtIndex:0]; UIViewController *detailViewController = [self.viewControllers objectAtIndex:1]; if (detailViewController.view.frame.origin.x > 0.0) { // Adjust the width of the … Read more

UITableViewCell Set selected initially

For the cell to appear selected, you have to call -setSelected:animated: from within -tableView:willDisplayCell:forRowAtIndexPath: like so: – (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if (/* should be selected */) { [cell setSelected:YES animated:NO]; } } Calling -setSelected from anywhere else has no effect.

Hiding the master view controller with UISplitViewController in iOS8

Extend the UISplitViewController as follows: extension UISplitViewController { func toggleMasterView() { let barButtonItem = self.displayModeButtonItem() UIApplication.sharedApplication().sendAction(barButtonItem.action, to: barButtonItem.target, from: nil, forEvent: nil) } } In didSelectRowAtIndexPath or prepareForSegue, do the following: self.splitViewController?.toggleMasterView() This will smoothly slide the master view out of the way. I got the idea of using the displayModeButtonItem() from this post and … Read more

UISplitViewController programmatically without nib/xib

Declare your splitviewcontroller in your delegate header, use something like this in your didfinishlaunching ensure you add the UISplitViewControllerDelegate to the detailedViewController header file and that you have the delegate methods aswell. remember to import relevant header files – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { splitViewController = [[UISplitViewController alloc] init]; rootViewController *root = [[rootViewController alloc] init]; … Read more

SplitView like Facebook app on iPhone

Facebook guys have done brilliant job in the new version of the app. The similar open source code can be found from here – JTRevealSidebarDemo. Please note that as of June 2014, this project has been discontinued, so you’ll probably have better luck with a project from the list below. It reveals technique behind doing … Read more

UISplitViewController in portrait on iPhone shows detail VC instead of master

Oh man, this was causing me a headache for a few days and could not figure out how to do this. The worst part was that creating a new Xcode iOS project with the master-detail template worked just fine. Fortunately, in the end, that little fact was how I found the solution. There are some … Read more