How to add Custom View class in XCode 4 iOS Project? - xcode

I create a subclass of UIView named "WebViewContainer", In Interface Builder 3 ,we can drag the WebViewContainer to MainViewController, but in xcode 4, I couldn't find that, in the "Custom Objects", it's empty:(

Drag a view object in to the window and change its default class to "WebViewContainer".
See this video on youtube http://www.youtube.com/watch?v=-u-Kdp-lYgM

Related

Linking storyboard view controller to its own viewcontroller.swift in Xcode 7.2

In the new Xcode 7.2 (iOS9), how do I add a viewcontroller.swift file and link it to a manually added view controller in the storyboard?
(This seems to be different than previous versions of Xcode where one would manually add a Cocoa Touch file after dragging a new view controller object in thestoryboard.)
Thank you.
It has always been the same for me but here are the steps that I follow.
Right click the file explorer on the left
Click Source->Next->Subclass UIViewController
Drag UIViewController into Interface Builder
Click the yellow circle to focus on the UIViewController
Click the Identity Inspector
Set the Custom Class to the name in your Swift File

How to select datasource and delegate in xcode 4.5?

I am c# asp.net developer and just a newbe in developing ios apps. I am trying some tutorials to build some uipickerview. But the most tutorials are using an xib file. My project is a storyboard project and dont have a xib file. So Iam wondering how I can connect my datasource and delegate from my uipickerview? In some toturials I see the "view controller scene" window in xcode, but I cannot find it in my xcode. So can somebody tell me what to do to show this "view controller scene" OR how to connect my uipickerview to the datasource and delegate?
The Storyboard is replacing the xib files and combines all your views into a single file for iPhone or iPad. To connect a picker view data source and delegate you can select the UIPickerView object in Interface Builder, go to the Connections Inspector (the menu with the arrow icon on the right) and there drag from the datasource to the view controller file owner.
Do the same for the delegate.
Then in the header file of that view controller you need to add the UIPickerViewDataSource and UIPickerViewDelegate protocols to the interface and in the implementation file implement the relevant methods.
Drag the delegates to the files owner in interface builder, you dont need a interface

Using XCode storyboard to instantiate view controller that uses XIB for its design

I have a UIViewController subclass that I created previously that had its controls laid out in a XIB file.
I'd like to use this view controller in a storyboard now, but it seems although I can indicate a view controller's classname in the storyboard, I can't tell it to load the XIB.
I'd rather not move everything from the XIB to the storyboard but keep it in its separate XIB.
How can I get this UIViewController in the storyboard to load my XIB?
Delete the View contained by the view controller in the storyboard.
Then provide the view by configuring a nib file with the same name
as the view controller class. For example if the view controller
class is called MyViewController, name your xib file
MyViewController.xib.
EDIT Note that Swift seed 5 started breaking this technique, because it mangles the name of the .xib file it's looking for. See my answer here for workarounds: https://stackoverflow.com/a/25539016/341994 Basically this name matching was broken in iOS 8, but then Apple repented and fixed it so that it works again in iOS 9.

Xcode 4 / Interface Builder "master" view UITabBarController template

I started an iPhone App with the Xcode template for UITabBarController, which created a couple of default UIViews (MainWindow, FirstView and SecondView).
The MainWindow xib shows the tabbar itself, which can be configured there.
FirstView and SecondView have an unselectable UITabBar anchored to the bottom, which is ostensibly to show the relationship to MainWindow.
Note that I've created many new views that are part of the main UITabBar and they work fine, but they don't show that UITabBar at the bottom in Interface Builder.
My question is, how does that work, and how can I create a new view such that it will show that unselectable UITabBar at the bottom?
What you're seeing is simply Interface Builder's "simulated metrics" and it shouldn't actually have any bearing on the app's behavior. But this is how you can change it:

Create instance of class in nib file

Im going through Apple's OSX Cocoa (Your First Mac Application) tutorial and am up to refactoring the app delegate. I have created my own controller class.
I don't understand how to "Create an instance of the controller class in the nib file". I'm using Xcode 4.
Drag an 'Object' from the 'Object Library' in the right pane onto your nib. Next, select the object that you dragged into the nib, and then select the identity inspector (third icon from the left in the top right pane). From these, you can set a custom class. Set the class to be the custom controller that you have created. This will be created for you when the nib is initialized. You can then connect this to an IBOutlet in your AppDelegate (for that custom class).
I think what you want is on the inspector, click the third tab, and for the "Custom Class", select your view controller.

Resources