Did it disappear ? In XCode 3 it did exist. How to create a subview class in XCode 4 ?
You want to create a template or class...?
A subview class can easily be created by File -> New -> Objective-c Class - > UIView Subclass ..->save
What's the problem in adding just a normal UIView??
Make sure you are choosing your xib file to be an iOS User Interface Empty file, not a Mac OS X one. In the latter, only NSView is available, not UIView.
Related
In previous versions of Xcode you could do New > File > Cocoa Touch Template to create a subclass of a UIViewController with the proper imports, viewDidLoad() method and so forth. This seems to be missing from Xcode 7. When I do New > File, Cocoa Touch Template is missing. I can create a new Cocoa class, but this does not subclass UIViewTemplate. Is there any way to create a view controller class quickly in Xcode 7?
Open Xcode
Go to File -> New -> File
Under the iOS section, select Cocoa Touch Class. Click next
For the section that says Subclass of: type in UIViewController. For the section that says Class: type in the name of your subclass.
Click next and save the file in the default folder.
If Xcode is not showing Cocoa Touch Class and showing Cocoa Touch instead, tap on the iOS section again and Cocoa Touch Class should appear.
Im playing with this project SquareCropViewController It is a helper for crop images to square. Inside project there are two versions, one made with auto-layout and one that works purely programmatically. I want to use programmatic version and integrate in my project, which works with storyboards.
In programmatic version there are several files
ProgrammaticController.swift
ProgrammaticController.xib
What is the sequence of actions to make it run in my project ? Do I have to create new viewcontroller and import xib inside it? If yes what is syntax ? I have never worked with xibs before and help will be much appreciated.
Thanks in advance
You should be able to just instantiate the class if it's hooked up correctly in the xib.
var controller = ProgrammaticController()
navigationController.push(controller, animated:true)
The file's owner's class needs to be set to the actual class in the xib for that to work.
I am experimenting with Interface Builder in Xcode 4.2 and iOS 5 on a old Mac.
In Xcode 3.2 there was always a MainWindow.xib file and it contained not only the File's Owner which was UIApplication IMHO, but also an App Delegate placeholder object.
I created a MainWindow.xib file using the Window xib template. The AppDelegate placeholder is missing, so I can't hook the window up to my actual app delegate object.
I suppose that I will need to add a placeholder object with it's class identity set to "AppDelegate" but couldn't figure out how.
Just drag out one of the blue cubes (called "Object") from the objects library and change its class to the class of your app delegate.
I'm using Xcode 4.4 and I'm trying to connect the .h and .m files to the view controller in my storyboard but the options I have for adding files are:
Objective-C class
Objective-C category
Objective-C class extension
Objective-C protocol
Objective-C test case class
Every tutorial and answer I have found is for the 4.2 version which goes the option of Objective-C subclass which I don't have. I was wondering if anyone knew how to do it in 4.4.
Thanks
I had the same problem and just found the answer.
First, make sure to read Xcode help about storyboard (in help menu, type story...)
Second, Make sure XCode show you his full interface (in the tool bar, select all three view icons, or at least the bottom right and bottom left icon.
There is a video in the help which explain how to do so.
why you have to connect .m and .h to the view controller ?
try the easy way: file - new file - objective c class and in the second windows check "with XIB interface".
with this, you'll get .m .h and .xib !
May sound like a stupid question, but I simply can't find the function of adding subclasses in XCode 4.3.2 anymore. I am sure, in the previous release of XCode I could choose the subclass of the view, before actually pressing the Create button in the dialog.
I was not using the storyboard, when I initially created my project. Is this the issue?
Thanks, René
File > New > Files > Cocoa Touch > Objective-C class > Next > Subclass of ...
OK, found the answer myself: File / New File / Cocoa Touch, Objective-C Class, Subclass of UITableViewController and set Option With XIB for user interface.