Creating a spit view app from single view ios - ios

I have run into a snag with changing a single view style app into a split view style app.
I have made it so I have the detail view set to the correct view controller, but dont know how to set up a table view for the master view. I created the table view as its own file outside of the storyboard and I don't know how to add it to the master view.
Also how should I link the two together in my code? The Table View was displayed as a popover in the single view version of the app, and it calls a method from the View Controller when a cell is selected. How would I implement the code to bind them?
Sorry if this seems noobish, but this is my first app and still learning.

Related

One Xcode iOS Template inside another

Does choosing any template while creating Xcode (Single View Application, Master Detail Application, Page Based Application, Tabbed Application) project means I can not change the application UI later?
Can I have Master Detail View + Page Based view inside a Single view Application?
Im new to iOS So please bear with me. Thanks.
You can make whatever changes you want. The original template you choose simply gives you an initial app with a storyboard setup with the minimum needed. The single view just gives you a single view controller. The master detail gives you a split view controller setup with a master view controller and a table view in a navigation controller for the detail view controller.
With that starting point you can add, edit, or completely replace that setup to meet your needs.

Adding a UICollectionViewController inside another UICollectionViewController

I am writing a project where I need to display a list of players (avatars) in a horizontal collection view controller / list, let's call this a HUD.
I want this HUD to be common, that is to say: I know this one component will repeat many times throughout the app.
I do not want to write the Collection View code over and over again.
I want to add the collection view to an existing view controller which already has a collection view.
Almost like an in-line Master-detail display where the master does not change from page to page.
Is there a way in Swift where I can instantiate the HUD collection View and append it to whatever View Controller I am in.
I have included a picture.
Thus my query is this:
How do I include a collection view controller inside another View controller that already has a UICollectionViewController?
How do I share this HUD component across multiple screens in the app?
Many thanks
I used a container view to solve my issue. This issue is now closed.

How to create simple tableview and load data using Swift in iOS

I am trying to create an app for iOS using Swift but running into problems with the very basics.
To keep it simple I just want the app to initially be a single view application with a button and some sort of list view on the page. I believe a TableView is what is recommended here. When I click the button, I just want it to populate the list/table view with some entries, that's it. To start with, I don't care if these entries are hard-coded, I just want to get something working.
I have been looking at different samples but I am getting confused. Some of them seem to suggest using a TableViewController others don't. When I use a tableview controller, the UI I had created seems to get completely replaced with just an empty tableview list and the button is gone.
I previously have developed apps in Windows phone and found it a lot easier. I'd just add a listview object and in the click method of button, add the items programmatically etc. But this is my first time trying to create an iOS app and it seems a lot more confusing. There are delegates, controllers, views all seemingly needed in order to do something very simple.
Can anyone give me some basic step by step instructions about how to add a tableview to an application and load some data into it through a button click?
Make sure you are clear about the difference between a view and a view controller.
iOS uses the MVC design pattern (Model View Controller).
A view object displays contents to the user and responds to user interaction.
A model object stores state data.
A controller object drives the app logic and mediates between the model and the view.
A UITableViewController is a special subclass of a UIViewController who's job is to manage a table view. It has some extra support in it that makes it a good choice for managing a table view, BUT... there is one annoying thing about it. It is designed so the ONLY view it can manage is a table view. You can't use a UITableViewController if you want to add buttons, labels, and other UI elements to your screen outside of the table view.
What I usually do is to create a create a table view controller, create a separate regular view controller, add a container view to the regular view controller, and then use an embed segue to embed the table view controller inside the view controller. (you just control-drag from the container view to the table view controller.) That way you get the best of both worlds. You may want to create a protocol that the table view controller would use to communicate with it's parent view controller.
You should be able to find a tutorial online on setting up a table view controller as a child of another view controller using container views and embed segues. It's quite easy.

iOS Different Views for Table View Cell items

I just started iOS development last week and I am creating a Table View based application. I having trouble understanding how to use storyboard.
I want each Table Cell to open a different ViewController.
Currently it is setup like this:
Then in the Component View Controller I use if/else statements to determine what content to load. The problem occurs when one of the views needed a TabBar.
How do I assign different View Controllers to each individual cell, rather than one "template" view and forced to add everything dynamically.
First off, I will say that it probably isn't the best idea to assign an individual view per cell. However, if it is what you wish to do, then so be it.
What you would do is create a segue from the table view to the new view by clicking on the table view icon and dragging a segue like so:
2.You would give that segue an identifier like "embedTweetsSegue" or something.
You can then check for the cell being touched and perform the segue programmatically using:
performSegueWithIdentifier("embedTweetsSegue", sender: self)

Calling multiple views from Uipopovercontroller list view contents

How can I call individual view controllers when I tap each row from my Pop Over List View in the most effective way? Meaning, I don't have to recode to build the Pop Over List View component in each of the individual view controllers, they can sort of share it like a navigation tool.
What I Have Built
I have built the pop over view controller list on my Main View Controller.
This is the 1st view that gets loaded when appDidFinishLaunching is executed.
So, when we run the app, this is what we get:
Link to screenshot of the Pop Over List View:
http://s14.postimage.org/63k567vtd/image.png
For each row in the above Pop Over list, I have a method where I can put in the codes to:
1. Identify which row was selected
2. Based on the row selected, do any action, like NSLog and stuff
3. All this codes sit in the Main View Controller
The Requirement
I am building a demo app, so all data is dummy data at the moment.
I need to call individual View Controller when each of the row in the Pop Over list is tapped.
Each of the View Controllers, will have their own set of data, own set of UI objects, its own XIB file.
So, if user taps on Applications, it must bring up the Applications XIB file and its functionality, followed by any navigations from here. If Application xib has a button that launches another view, this functionality should be in place too.
However, they all must have the same top Navigation Bar with the Pop Over list button, so user can tap that button and see the Pop Over list anytime in the app.
Please share your view.
Thank you.
I suggest looking in to UISplitViewController. It is a component built by Apple to manage what it looks like you are trying to accomplish. Essentially, you set it up with 2 view controllers; the first (called the "master"), would be your table view. The second (called "detail") would be the view controller that gets switched out.
Once you explore it a little and are comfortable with the terminology, here's the general advice:
Inside the master table view controller's didSelectRowAtIndexPath: method, instantiate the appropriate view controller (based on the indexPath), and set it as the detail view controller, like this:
- (void)tableView:tableView didSelectRowAtIndexPath:indexPath {
UIViewController *newDetailVC = // make and configure a new VC based on indexPath
self.splitViewController.viewControllers = [NSArray arrayWithObjects: self, newDetailVC, nil]];
}
Here are the appropriate links:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UISplitViewController_class/Reference/Reference.html#//apple_ref/occ/cl/UISplitViewController
and further (the later sections of): http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html%23

Resources