iOS Development: How can I build a complex structured iPad Application? - ios

I have a scenario with 3 sub-applications embedded into a main one.
I'm trying to use the splitviewcontroller to change my detailview's content, but I couldn't replace the detailviewcontroller without losing the popover.
Questions:
1-How can I build a organized structure to maintain my project?
2-How can I replace my detailviews viewcontroller by another?
3-Should I use storyboard or separated XIB's?
4-Can I "call" a splitviewcontroller from a simple view? (Login(single)->AppSelection(single)->App1(splitview).
Here is a sketch of my project

Looks like you've already got it mostly storyboarded, so I would definitely recommend that approach!
I wasn't able to figure out how to segue to a split view using just storyboards and nothing else. You will have to get the button press and replace the window's rootViewController with your split view (which you could load from a storyboard, or just a plain nib, if you wanted.)

Related

Best approach for 1 screen contains 2 view controller

I want to learn parent - child concepts in iOS. I found a some app in app store and I liked the their design. They have 3 button in same view controller when the user taps a button below view changes and calls their view controllers. Like a TabBar.
I tried to create 3 xib files. When the user taps the buttons they are awaking from nib and I added them to my containerView subview. It works. But I couldn't send a data between them because there is no prepare for segue method to so i couldn't prepared them.
I tried to create 3 viewController in Storyboard and I use them with the Storyboard ID. It works. But still can't transfer data between them.
I didn't understand what is the best approach for solve this problem ? I researched on the web about Custom Segues and Parent - Child concepts but I couldn't find anything.
What is the best approach for make a container like in the image ?
Thank you.
I am not sure if there is something like a best approach, at least in general term. It really depends on your specific demands and other logic of your app.
Both creating XIB files and creating ViewControllers in Storyboard together with their ID is ok. Here it is more about your preferred way. I would say that today you will probably see more using Storyboard than XIB files.
In terms of data transition. There are several ways, if it is not some very heavy logic then delegates can do it pretty well and easy.

Using multiple copies of the same view controller in a storyboard

I have the following setup in my app:
My initial view controller is a UITabBarController.
the tabs:
1)UINavigationController->PostListVC
2)UINavigationController->CategoriesListVC
3)UINavigationController->PostListVC
4)UINavigationController->PostListVC
5)UINavigationController->MoreViewController
As you can see, 3 tabs contain the same viewController class, but should not contain the same view controller object - the view will display different information based on information he gets form the AppDelegate.
What I did is I created 5 UINavigationControllers, connected them to the uitabbarcontroller, then created a rootViewController segue for 3 of them to the same PostListVC View - that way I don't need to maintain 3 designs of the same view.
The problem that I get is that only the first PostListVC gets created properly ( the leftmost in the tab bar ) - the other tabs that point to a PostListVC just show a black screen.
I've tried to illustrate the way I wire-up the storyboard using a 3-tab example:
As you can see, both the upper-most and lower-most views are connected to PostListVC.
I do not know what the issue is. I assume I'm using storyboards somewhat wrongly.
Does anybody know how I can fix this?
Thanks!
EDIT:
I have created a simple, example project (Xcode 5) that illustartes this issue:
http://www.speedyshare.com/Srwfg/TabBarProblem.zip
EDIT 2:
A modified version of the example, showing the problem with the offered solution:
http://speedy.sh/JkdGC/TabBarProblem-2.zip
There is no way to create different tabBarItems with this method, and there's no way to place the barItems so that they're not in a row - even if you try to chagne the order of segues.
As you said you need three different instances of PostListVC then you should create three different viewcontrollers of type PostListVC and connect each tab to its own. The class is the same but each tab gets its own instance.
I have got your example program to work BUT I don't know if the solution will work for your full project. Hopefully, it will put you on the correct track.
The solution is to have ONE (1) Navigation Controller / embedded root view but TWO (2) segues from the Tab Bar Controller. Here's the picture:
It looks like there's a problem with multiple UINavigationControllers linking to the same UIViewController. But no problem with the same UINavigationController linking to the same UIViewController provided they are instantiated separately through the UITabBarController.

Do I need multiple view controllers for the iPhone & iPad storyboards?

I'm still relatively unfamiliar with all the new features of iOS 5, and what I can do in Xcode now. So, a good explanation would be appreciated.
I'm designed a single-view application and I have both an iPhone and iPad storyboard. I chose 'Single View Application' when I first started, so Xcode created a ViewController for me. Both storyboards list this view controller as their own.
Back in iOS 4 the way that I linked button actions to my view controller was to Right-Click on the button on the nib, pick the action that I wanted, then drag it over into the view controller's '.h' file, which auto-created a method/property for me.
I am confused about how to accomplish this now, since I have multiple storyboards but only one view controller. Do I need to have multiple links for each button; one for the button on the iPhone and one for the iPad? Or is there a better way to accomplish what I am trying to do now?
You do it the same way you did it in iOS4. But obviously you never built an universal app there ;-)
It's totally okay to have a single UIViewController class for two different nib files.
And if you use storyboards it's fine to use different storyboards and a single viewController too.
You can even use the same viewController for different scenes inside a single storyboard.
The connections to the viewController are saved in the nib or storyboard. So you can't overwrite them while designing the other user interface.
Open the iPhone storyboard, make your connections to actions and outlets. Then open the iPad storyboard and make totally independent connections.
In response to the first reply, I was under the impression that a view controller could only support two scenes in a storyboard layout. I say that because I found this thread.

UISplitViewController on iPad with Storyboards?

In Xcode, how can I create a simple iPad application that uses Storyboards such that the DetailView controller is swapped out for each entry? Most examples that I've seen use the iPhone or they simply change the values in the same detail view controller.
I want to create the segues in Interface Builder from a static TableView Controller (with say 3 rows) where each row will load a different game detail view controller, which I would drag out and design in IB. Currently, when I connect a view controller with a segue, it replaces the navigation part of the UISplitViewController. In other words, it's like I'm traversing a tree, and I need to tell IB that I'm at a root node and I should be changing the Detail View.
A good starting point for segues are Lectures 6 and 7 of Stanford's CS193p Fall 2011 class.
http://itunes.apple.com/us/itunes-u/ipad-iphone-application-development/id473757255
The instructor, Paul Hegarty, covers everything. However, he runs out of time before the end of class to answer this question. He does include the source with the final solution in the file: Psychologist with Dr Pill.zip.
http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2011-fall
Basically, all that needs to be done for this question is to Ctrl-drag from each UITableCell to the respective game detail view controllers then select the Replace segue. There is one more step because the view controller will shrink because by default Xcode thinks that you want to replace the master controller. For each of the segues, select the connection line and in the Attributes inspector then change the Destination from "Master Split" to "Detail Split". At this point, you can test with the popover, without writing any code.
Apple has provided sample code of a more general solution to the problem of how to swap out different detail views based on what is selected in the master view. The Apple example code accomplishes this by introducing a custom implementation of the UISplitViewControllerDelegate protocol:
https://developer.apple.com/library/ios/samplecode/MultipleDetailViews/Introduction/Intro.html
Hard to describe without pictures but: have a navigation controller as the master. Then hang each detailview off this with a named segue that replaces.
Then you need a bit of code.
In you master viewcontroller inside didSelectRowAtIndexPath, you need a switch statement based on indexpath.row and in each row call detailview performSegueWithIdentifier:#"the row you want"

Using Storyboard how to interact with viewcontroller objects

I've reviewed many websites and youtube videos that have IOS 5 storyboarding information. Most of them are pretty basic and only describe how to get started with storyboarding and how to segue into other views. I'm interested in taking it a step further and actually adding custom code to the views contained within the storyboard.
Is the "normal" workflow when creating an IOS app using storyboard?
Create the layout of an app using storyboard (adding views and objects to those views).
Create viewcontroller files (.h and .m), one for each view contained within the storyboard.
Hook up the scenes from the storyboard with your own view controller subclasses by editing the "class" values in Identity Inspector.
I believe I followed those steps, but when I implemented step #3 above and ran my application, I was only able to see a black screen. The view I had created in storyboard wouldn't display.
You have the right steps. Make sure you create your .m and .h without a xib. Post your code for the view controller for your first view to get more help.
yes, this is the normal workflow. have you set the "initial viewcontroller? ?
see this image: http://dl.dropbox.com/u/31437518/Screen%20Shot%202012-01-24%20at%2012.29.34%20AM.png
It sounds like you made a storyboard file but it isn't being loaded.
Do you have the main storyboard setting in the target summary screen filled in?

Resources