UISplitViewController with custom master view controller that is not UITableViewController - ios

I'm working on an iPad application that requires a UISplitViewController. For the Master view controller I would like to use a custom view controller that has an image, a table view , and a label. Out of the box the UISplitviewcontroller/MasterDetail template give me a Navigation controller with an embedded UItableViewcontroller. When I attempt to change out the tableview controller for a new Viewcontroller the view for the new controller is not being presented. I am able to set the UIBarbuttons but none of the datasource methods for the table view are being called. Also the imageview and the label are not being presented. I've made sure that my view controller is the delegate and datasource for the tableview and set the preferred size in the awake from nib still no UI. I'm adding the UISprlitviewcontroller to an existing project could this be an issue?

The issue was with the use of size classes. Since this is an iPad app only I turned off the size classes option and the app is working as expected. I need to invest time in learning how to properly use this new feature.

Related

Pushing detail controller from cell of programatically created UITableView inside another view controller

I have a custom UIViewController that we'll just call ViewController. I'm using this library to have a view controller effect where one can slide left and right between pages. My pages are a programmatically created UITableView subclass. To be more specific, each page is a Day and the title of the page is the day of the week, and the cells in the UITableView subclass are events for that day.
I want to push to a new view controller when I touch one of these cells but I'm stuck. I want to push to a view controller that I've created in my storyboard and pass an object through that push that populates the view controller. My navigation controller I use in ViewController is created in storyboard. The custom UITableView is created programmatically.
Some errors I've been getting:
-- Application tried to push a nil view controller on target .
-- And also self.navigationController is nil.
I have no idea how to do this and there doesn't seem to be any helpful answer out there. I'm completely stuck. I've attached an image of my ViewController, and if you check out the linked GitHub repo you can see how I'm using the provided code there.
I figured it out using a delegate. I pass a delegate in my subclass UITableView back to my original ViewController. In my case it was an object. Check out this link:
How do I set up a simple delegate to communicate between two view controllers?

Multiple Views For One Controller in Swift

I have a controller called PageViewController. Now I have created several view controllers in my storyboard. Ideally I would like to connect all of the view controllers in my storyboard to PageViewController and then when PageViewController is loaded, PageViewController will choose which view to display to the user.
I don't want to create the view programmatically since I'll also have to create numerous layout constraints to each view and that will be time consuming. My questions is this, since I connected multiple view controllers to PageViewController, is there a way for me to tell my app which view controller from the storyboard I want displayed for PageViewController.
Not sure of what you want but you can get your controller from your storyboard using its identifier :
let controller = self.storyboard!.instantiateViewControllerWithIdentifier("myControllerIdentifier") as! MyControllerClass
You can present it using presentViewController:

How to create a separate view in Storyboard to be included programmatically in UITableView?

I have a UIViewController with a UITableView that is fed with data from the local database. When the user first launches the app (after installing) the table view is empty and I display a UIView in the middle of the table view that contains a UIImage, a UILabel and a UIButton (a call to action).
The first version of this view I built programmatically, which was no good to me because every time I tweaked something I had to build the app again. Then I switched to the storyboard but had to drag a UIView to the middle of my tableView. It is working now but I don't like the way it is, I can't edit my table view cells without having to move the UIView out of the table view.
I'd like to have a way to build this view entirely separated from my tableView (or even from my view controller in question) and then reference it in the viewDidLoad call of my view controller.
Unfortunately Xcode does not allow us to drag views directly to the storyboard so I'm pretty lost here.
Please tell me if I haven't been clear enough. I appreciate any help you could give me.
UPDATE: It'd be particularly awesome to me if I could also create a custom Swift class for this view of mine and reference it in the storyboard. And then in my viewDidLoad I could simply instantiate my custom view.
Thanks in advance.
Create a XIB file in which you can drag a view (without a view controller).
In your code you can load the XIB using NSBundle.mainBundle().loadNibNamed("MyXibName", owner:self, options:nil).
In the XIB file you can give the UIView a custom class (like you can do with view controllers in storyboard).
You then of course have to retrieve the view from the array returned by loadNibNamed and cast it to your custom class.

Best practice to develop common header view across all controllers/windows in iOS app

I'm keeping on developing an iPhone app (rigth now native one) and I would need to use a common "header" for all views but I don't want/need a UINavigationBar and prefer much more have a common "partial view". It will have some actions to perform but always the same ones (showing notifications panel, basically). It should be something like you can see in the screenshots.
I don't need (I feel) delegation because the controller's view can handle notifications and show them when user clicked the customize button.
I don't mind to use a Nib o make the view hardcoded but I'm not sure how I must make an instance of the view or the controller that handles it within each app tab (I'm using UITabBar as navigation control).
From my point of view it doesn't exist a way to get a common controller to call wherever needed; you just can use some method to present new controller as modal o push it out and I think that is not what I'm looking for.
Any idea is welcome. Thanks
Create a custom view controller with 2 subviews. Subview 1 is the header. Subview 2 is the container view where child view controllers are displayed (your tab bar controller in this case).
Your custom view controller could be the delegate of the tab bar controller if you want, so it can be notified when the tabs change and update anything on the header view.
Well, finally is have used the solution I found on the link http://patientprogrammer.wordpress.com/2012/03/12/re-usable-subviews-in-ios/
I have created a Nib with a view controller and then, in the main window I have added two view, the top one subclasses the view controller for the Nib view and it is rendered automatically when app is launched without a single line of code within "main" controller. See the screenshots for more detail:
Thank you very much for your help

iPhone : UINavigation Controller within a view displaying another view

I think I am having a case of disappearing up my own arse.
I am creating a small view on a ipad thats for settings (so not full scree), within this view. I need a navigation controller to show another view.
At the moment I have one class / xib
The xib contains the main view (graphic / boarder). This view is linked to the files owner and appear.
On the same xib, I also have a navigation controller that contains the inner view.
OnViewDidLoad I add the navigationcontroller.view to the subview and it appears. However I cant push anything off it. I wired up the delegate and etc but I am sure I am missing something stupid
Can I do this all within one controller / xib?
The only code I have done is
[self.view addSubview:mainNavigationController.view];
Is there some code I need to do for the navigationController
Just adding the navigation controller as a subview doesn't hook up the navigation controller to the view controller hierarchy properly. That's probably why it doesn't work.
Also the properties that need to be set are readonly properties, so I don't think there's anything you can really do about it.

Resources