In android I would create a single layout and then use it with include in another layout xml file. Like this I can share single layout with multiple activity. Now in iOS XCode I want this approach to share single view created as .xib into multiple storyboards. I can see a View Controller but I don't know how to include view .xib under that View Controller. Any idea?
According to your Comment, you need to add that .xib view programmatically on your desired controller
e.g.
[ViewInWhichYouWantToAdd addSubview:xibController.view]
Related
My app has multiple screens all of which are different and not related however i must have a burger button which opens the same drop down menu on each screen.
Is it possible in iOS to create the menu once as a view and reuse it on each screen or do I have to create it on each ViewController and implement it.
Any explanation as to how to achieve this would be great.
The best thing would be to implement a custom view or custom control which you reuse in every Controller you want. The good thing is with the new storyboard and a xib file you can even see it in realtime in the storyboard (#ibdesignable).
Check out this: Creating a Custom View That Renders in Interface Builder (Apple Documentation)
Or a great tutorial: Custom UI components
Is there a way to share a view across multiple view controller? This is for making a cheat console for my app, and that console UI should be available through out all the view controllers.
Thanks in advance.
You can create a xib file with your view, then create a class and specify this class in the view file's owner. Then you can create outlets from the xib to the class.
And then follow this article to initialise and use the view:
http://onedayitwillmake.com/blog/2013/07/ios-creating-reusable-uiviews-with-storyboard/
Instead of a view, perhaps you may want to expand what you can do with your cheat console, and instead create a seperate view controller for your cheat console, then you have your other view controllers call it as a pop over. If you are doing it though UIBuilder, when you create the segue, you would set is as Present As Popover
Basically until now I create a ViewController in the Storyboard, set its class in the identity inspector and implement the connections and behaviour in the class.
Now I have two ViewControllers (ViewControllerFoo and ViewControllerBar), both are visually the same, but the information and the implementations of the actions of the buttons are different. So I want to create a BaseViewController, with the view creation and common implementation and override some methods in the ViewControllerFoo and ViewControllerBar
If possible I'd like to keep both ViewControllers in the StoryBoard in order to create the segues that launches each one of them visually
How can I do this?
Note: I'm starting with iOS development.
View layout is something that works with view not with view controller.
You can create a simple .xib (or view) file and draw your layout here.
After that add this view to controller or specify that view as main view of this controller.
Or you can create a view class and place all elements programmatically.
Just think about storyboard as 'navigation' utility not 'view layout' utility.
Note: too many views on storyboard speed down your computer and look too ugly.
Draw view in xib to reuse it or create custom views classes/clusters to implement interesting UX/UI effects
I'm creating an app which includes a lot of re-usable views.
For this to work I created my main storyboard, and then the xib files for the re-usable views.
I then figured out a way to 'extract' the view from the xib file (drag the view out of the controller) which gave me the ability to freely resize the view in the xib file.
The outcome was that I had a bunch of custom sized views (xib's) and my main storyboard which would dynamically build lists from the xib files to use as sub views on it's main view.
Everything works perfectly in the simulator, but my question is, is it 'legal' to do it this way. Or would apple reject the app?
Thanks
Its ok to do so,Infact you can created custom sized views in storyboard itself but they will be embedded in viewcontroller anyway
Make the size to freeform in the attribute inspector of viewcontroller and you can have the customised sized view in viewcontroller itself
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?