How to add initial view to Storyboard file? - iphone

I started an "Empty Application" template, this means that I had to add my own storyboard file. Problem is, it is completely blank, and I can't figure out how to get the first view on there, so I can start designing my interface.
Anyone know how to get that first view on there?

When you create a new Storyboard file, all you need to do is click/drag the UIViewController object from your right hand side of tools into your Storyboard and then you're all set to begin work on your new Storyboard.

Just in case you can not start from scratch :
Select your View Controller
Open the Attribute inspector (right pan by default)
Go to View Controller section
Select Is Initial View Controller checkmark of the Initial Scene option

In the latest version of Xcode (12.2), this is how you can add initial view to story board
Click on + Icon,
search "View Controller", Drag and drop View Controller.

Go to Edit->Show Library then drag and drop a type of View Controller that you need.

Related

How to edit a View hidden behind other Views in Xcode Storyboard?

Is there an easy way in Xcode to edit a view that is hidden behind other views within the Storyboard? I know I can hide the views in front of it and move the view to the front temporarily, but this is difficult to keep doing over and over again. Is there a way to isolate the view somehow in Storyboard so I can edit it on its own?
Select your view controller in storyboard and Open File Inspector
Select Use Auto Layout and Use Trait Variations
Now select the view you want to hide in your storyboard. Open Attributes inspector. Check/uncheck the installed option to show/hide the selected view. You can hide multiple views by changing this property after selecting all the views.
Don't forget to check this option for all the views while running the app. Else it will crash

Simulator wont start on home TableView

I've created a table view which is embeded in a Navigation Controller as such and connects to another view controller. I've the connection from the table to the navigation controller as a modal segue and the segue from the table bar to the View Controller as a push segue yet I am still getting the error:
Unsupported Configuration
Scene is unreachable due to lack of entry points and does not have an identifier
for runtime access via -instantiateViewControllerWithIdentifier:
This worked last week and now its not. Ive tried adding storyboard IDs but thats not working. I appreciate any help.
Did you check your start point in your storyboard? In other words, on the left side of your starting navigation controller, do you have the arrow pointing to it? If not, drag it until you make it point to the navigation controller.
Also, if you're doing that dynamically, have you provided your UIViewController/UITableViewController/UINavigationController Storyboard IDs? Please, double check that by clicking on your view controller in your storyboard, then in the Inspector (right side of Xcode window), go to the third tab and make sure you have set the ID and make sure they are consistent with your code.

Connect outlet between table view and viewcontroller with storyboard

I'm trying to connect an outlet between a table view and the viewcontroller.h by using drag and drop. I'm using this tutorial. My problem occurs at the following instruction:
Select the Table View object and display the Assistant Editor using
View -> Assistant Editor -> Show Assistant Editor menu option.
Ctrl-click on the Table View object in the view and drag the
resulting line to the area immediately beneath the #interface directive in the Assistant Editor panel.
Upon releasing the line,
the connection panel will appear. Configure the connection as an
Outlet named tweetTableView and click on the Connect button.
I do not get the option to connect the two (by drag and drop). I have done it with a webview before and that all works correctly. The dragging also works for me in the storyboard itself but not when i drag to the viewcontroller.h file. Maybe its my storyboard setup; that is as follows:
Tab bar controller (Start point)
Navigation controller ---> Table view controller
View controller (with webview inside )
Could anyone please help me?
You have a Tab bar? Then, you must have another viewcontroller (let's say viewSecondViewController.h) associated to the second tab bar..
In that "ViewSecondViewController.h" you can drag and link...

How to change the default View Controller that is loaded when app launches?

I have an application, say 'MyApp', which by default loads the view controller 'MyAppViewController' whenever the application launches. Later, I added a new view controller 'NewViewControler' to the project.
I now want the 'NewViewController' to be my default view controller which loads when the app launches.
Please let me know what changes I need to make in my project to achieve this.
Its easy, just:
Open your Storyboard
Click on the View Controller corresponding to the view that you want to be the initial view
Open the Attributes Inspector
Select the "Is Initial View Controller" check box in the View Controller section
Open MainWindow.xib and replace MyAppViewController with NewViewController.
In your app delegate class, replace the property for MyAppViewController with one for NewViewController. Connect NewViewController to its new outlet in Interface Builder.
In application:didFinishLaunchingWithOptions: add NewViewController's view to the window instead of MyAppViewController's view.
Most likely your main NIB file is still set to "MainWindow", check your *-Info.plist file.
If that's the case you can open the MainWindow.xib in Interface Builder. You should see a View Controller item. Bring up the inspector window and change the Class Identity to point to your new class. That should take care of instantiating your class.
As this feels like a "newbie" question (please pardon me if I'm mistaken) I would also highly recommend the following article:
iPhone Programming Fundamentals: Understanding View Controllers
Helped me understand the whole ViewController thing and the IB interaction..
As for me with xcode 4.3.3, all I had to do was simply replace all references of 'MyAppViewController' with 'NewViewController' in the AppDelegate h and m files.
Perhaps all the other steps have been taken out in the newer versions of xcode.
Hope this helps.

Easy custom UITableView drawing

All,
I found the code in Matt Gallagher site ( http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html ) for this really neat design for a Table View... Im very new to Cocoa and Im having a hard time figuring out how to wire the darn thing in IB...
I loved the design and wanted to use something similar in a more complex structure... Nav Bar / Tab Bar with a few other views / TableView for the data in the first view... I found lots of tutorials to do that and got it working... When I tried to use that design in my project, things went crazy... in My MainWindow.xib I cant have a UIView where the arrow is pointing...
the nib looks like this:
Tab Bar Controller
Tab Bar
Nav Controller
Navigation Bar
Table View Controller
Table View
---->>>> (UIView for the backgroundImage )
Navigation Item
Tab Bar Item
UIView Controller
Tab Bar item
Window
can anyone guide me in the right direction??
Thanks !!!
It sounds like you're not having issues with the table view as much as the construction of the hierarchy around the table.
Instructions for creating the hierarchy would be as follows. I think you've diverged at around step 9:
Start with new copy of the default iPhone "View" template
Throw away the view controller class.
Open the MainWindow.xib and delete the view controller there too.
Find the controllers in the
Interface Builder library palette (they're
the yellow spheres at the top of the "Cocoa Touch" library in "Objects" mode whose icons contain
other objects).
Drag the tab view controller into
your MainWindow.xib file at the top
level.
Expand the tab view (triangle next to its name in the list view of the xib)
Drag a navigation controller into your expanded tab view (if this works, it should appear as one of the tabs along with the two view controllers that are there by default)
Expand the navigation controller
Drag a view controller (not a table view controller) into the navigation controller. It should appear as the content of the navigation controller.
Select the view controller (single click).
Press Command-4 (or select "Identity Inspector" from the "Tools" menu).
In the "Class Identity" popup menu, select EasyCustomTableController (this assumes that the current xib file is part of an Xcode project and this Xcode project already has EasyCustomTableController added to it).
Add a UIImageView to the view controller's view (this is your background image)
Add a UITableView to the view controller's view (this is your table). Add this view so it is after (and hence on top of) your image view.
There should be a tableView outlet on the view controller. Connect this to the table view.
Connect the app delegate's viewController to the tab bar controller (back in Xcode you can optionally change the type of this property to UITabViewController)
Should work.
The trick is that UITableViewController can't be used if you want the view to contain more than just a table. For this reason, you must use UIViewController and recreate the functionality that the UITableViewController adds. See here for how this is done:
http://cocoawithlove.com/2009/03/recreating-uitableviewcontroller-to.html
Thank you Matt (kind of cool that you answered)!!
I really appreciate the help... I've been messing around with it and got it to work using a UIViewController in another view (being created from the tableview)... Once I had the UITableViewController in the navigation I dropped the imageview & used a gray color; it looks great!! The initial screen has the rows big enough that scrolling is not an issue... I will go back and try to change that now...
I do have to say that IB is by far the most challenging step in app development for a newbie coming into Cocoa Touch !!! Yikes!