I am creating an application where there are some views i want to be available in each and every UIView Controller just like a master page in Web Development. i have created those views but how to add them to all the view controllers in the application automatically?
You should add them to mainWindow if you need to display them in all viewcontrollers.
Hope it helps you.
You need to convert the project and all the views that you created to a template first and then create a new project and use that template. Here is a guide I have used:
This guide explains how to create new project templates in Xcode. Project templates appear in the list of project types in the New Project dialog.
1.Create a new project and setup everything as you'd like (NIB files, graphics, sounds, settings, code etc)
Optionally, build and make sure the project works
Use Finder and locate the project folder for your project you created in step 1
Open another Finder window and navigate to /Library/Application Support/Apple/Developer Tools/Project Templates/. You have two options here:
Create a new folder for your custom project templates - this will appear as a category when creating a new project in XCode
Choose an already existing folder (eg Application) - this will place the project template in that category
5.Open the new/chosen category folder and create a new folder inside. You can name this new folder whatever you like and it will appear as the project template name.
6.Copy all files from the project folder in step 3 to the new template folder created in step 5.
7.Try to create a new project in Xcode. You should see your project template in one of the original categories or in the category you created, whichever you decided.
Note: If you built the project, delete the build folder from the template folder.
Hope this would help you out.
Create a base view controller class which will have all these UIViews added in its view. Additionally, you can also implement the events of these particular views in the controller. Other controllers that you create need to extend from this base view controller class.
Related
I am trying to create a contact form with validation in Croogo, I don't know where to create the ctp files and the controller for it. I did this in cakephp but I could not do the same in Croogo. Help me with this.
I have created it in the nodes folder. As this is the first time I am using this I struggled with it. I have created the view files and the controller files in the respective view and controller folder in the nodes folder.
I created an EMF project and tested using <>.editor project generated by .genmodel file by creating a new project and a file through "Example EMF Model Creation Wizards". Is there any way that a view (in plugin project) can be created directly (probably project & file are automatically created when user runs the application)? I dont want the user to create these things. It should be automated and presented in a view.
In the .genmodel file, set .genmodel --> All ---> Runtime Platform to RCP. This creates an RCP app that does not use all the plugins of the IDE. If you want, you can generate your app to run in the IDE... However, for this answer I will simplify and assume you generated an RCP app. Go into the XXX.editor generated plugin, and into the .plugin file --> extensions. Add a new (org.eclipse.ui.views) View by declaring a new View extension -- see the Sample View for a template. Make sure to keep track of the ID you give this new View extension. Similarly add a new PerspectiveExtension extension. Add a reference to this new PerspectiveExtension with your unique View ID. In the View extension, click on the class link, this will create a skeleton ViewPart class. It is a good idea to put a public static final String YOUR_VIEW_ID = "com.yourplugin.ViewID" in that class.
This will get you started and if you added your new view to your perspective, it should be visible when running your EMF based RCP app.
I'm writing my first iPhone app. I needed a custom switch (I want it to say "Male/Female" rather than "On/Off"), and I found RCSwitch but I'm having trouble figuring out how to integrate a downloaded widget into my project. I assume this is a fairly common thing to do, but I can't seem to find any documentation online on how to use a downloaded widget / class.
I have succeeded in adding the code in via Build Phases -> Link Binary with Libraries. An RCSwitch directory appears within my project tree, and if I do a diff I see that it has added code related to RCSwitch to the header files.
The problem is getting the widget onto the .storyboard image. The RCSwitch widget itself does not appear in the "Objects" box -- the one that is by default at the lower right of the screen and includes images of the widgets that you can drag into the storyboard. Perhaps I'm missing something?
from the xcode 4 transition guide (pg. 65):
Drag a custom view object from the library into the nib file.
After adding the custom view to your nib, select the custom view and
assign the correct class to it in the class field under Custom Class
in the Identity inspector
Some more resources:
iphone-creating-custom-objects-for-interface-builder
Interface Builder Help - Custom Object
This question is simple... you have a choice of which Template you'd like to use when creating a new iPhone application in Xcode.
What if I choose a View-Based, but I need a Navigation-Based application too? Can you combine the various templates within a project? I mean, is it just a matter of creating a new .xib file and dragging on the various UI components?
The navigation based template is also view based. Look at the code, the navigation based template contains a rootViewController which loads its view from a xib file.
You cannot combine templates automatically you'll have to do it yourself.
You can always create custom templates as you want. You just need to pick a template from Xcode then you can modify it as you want and just place it on a proper location.
Read my this blog post for a better understanding - http://www.makebetterthings.com/blogs/iphone/how-to-create-xcode-project-templates/
Looking for the best way to set-up an iPhone project in XCode ... namely:
What is the preferred project template to start with (e.g View-Based or Windows-Based application)?
What folder structure should I create in XCode to manage the project? For example, under "Classes" is it a preferred practice to add Models, Views and Controllers sub-folders?
Any other best practices, tips, etc... would be appreciated.
Thanks
Take the most "complicated" template, based on your level of knowledge. I usually start out with the "Window-based application" myself, and add components one at a time from there.
I keep all of my code (.m/.h/.c/etc) in the "Classes" folder and only rarely add subdirectories to it. One exception is a "Generated" subdirectory for classes generated from Core Data entities.
When I create a new UIViewController subclass, I rename the resulting .xib to remove the "Controller" part; i.e. MyViewController.m gets paired with MyView.xib. (I think MyViewController.xib reads funny, as the xib isn't for the controller, it's for the view.) I also move the .xibs into their own directory next to the project file to keep things tidy.
There is no "best" template. Window-based is the most basic, while View-based starts you out with a view and a view controller.
I'm with Shaggy Frog on renaming xib files to not have "controller" in the name. However, I like to create groups to logically separate functionality, and in those groups I place view controller code along with the xib files those view controllers use. Then you know what belongs with what.
I also like a create a top-level "Application" group into which I put the app delegate, main xib file (if any), pch file, info.plist, app icon, Default.png and other things related just to the application so they are all easy to find - after you add a number of files each of those things can get lost in giant lists of stuff.
Basically organize things so you can find them, a structure that makes sense to you might not to someone else.
Window-based provides you with the most flexibility, and is probably what you want to choose after you've got a couple of projects under your belt. I find with the other templates that I'm usually removing too much code, and it would be quicker to just start from scratch.
I usually setup my projects by creating 4 subfolders under Classes: "Views", "View Controllers", "Model Objects" and "Helpers". Model objects contains all the basic object types, where as Helpers contains things like utility classes or similar. Sometimes, where relevant, I will also create a Table Cells folder underneath both Views and View Controllers. I move MainWindow.xib to the Views folder.
If the project is large, I will sometimes also have sub-folders for the Views and View Controllers based on the UITabBarController tabs. So if I have 5 tabs, then the Views folder will have 5 sub-folders, as will the View Controllers folder. I find this helps to keep everything logically together in the same place.
One other thing I do is create an Images folder under Resources, otherwise that folder gets way too cluttered very quickly.