Modifiying Nib file without Interface Builder - iphone

I was wondering if there is any way to directly manipulate the XIB/NIB files without the use of Interface Builder. I know its difficult but is there any way. Can you please tell me how can I do that or the internal structure or the documentations available on it? And will it be feasible or better in any other way.
Regards,
Vivek

Xib/Nib files are XML files, you can edit them with every Texteditor.
I wouldn't recomend that tough, if you want more controll over your app, simply create your views Programmatically. A little introduction for doing so might be: http://chris-software.com/index.php/2009/04/29/creating-a-view-programmatically/ further reading to remove nibs completely from your app:http://www.steili.com/wordpress/2009/02/25/building-an-iphone-app-without-interface-builder/

Related

Best practices of theming/skinning an iOS app?

What are some best practices of theming/skinning an iOS app?
Examples:
Using custom images as screen backgrounds.
Modifying the look of UITableView tables.
Buttons with a custom look.
Links to good tutorials are a plus.
You can create a protocol that defines methods to return theme-specific colors, images, etc. All classes that conform to this protocol have to implement these methods.
#protocol MyCustomThemes <NSObject>
-(UIFont*)writingAreaFont;
-(UIColor*)dataCellLabelColor;
-(UIImage*)dataCellBackgroundImage;
#end
I can suggest that:
Make theme class
Make function to return background image(s)
Make function to return data cell.
make any required function in the theme class.
the init function should have one parameter to plist file that contains the assets(images) that will be needed for your class to work properly. it should be a plist file that contains a dictionary for a predefined keys.
I hope that helps.
You might take a look at NUI, which lets you modify the theme/skin of an app very easily, and save that theme for other apps, too.
For example, if you wanted to use a custom image for the background of all of your UIViews, you would just put the following in the NUI style sheet:
ViewBackgroundImage String MyImage.png
NUI supports styling for UITableViews and UIButtons, too (as mentioned in your other examples).
You might want to check out Freestyle. It's built on Pixate, and styles your app with structured Sass. You can do as little as change the variable values to make a new theme, or extend and customize it via CSS or Sass.
Old question, but still - if you're looking for best practices, then UIAppearance is probably it.
However, if you're looking for a more powerful way to style your app (and create themes) - also have a look at InterfaCSS. InterfaCSS uses stylesheets inspired by CSS (and Less/Sass) that support a rich selector syntax and lets you use standard UIKit property names.
I know this may be late but I've stumbled upon a theme framework called Pixate. Pixate allows you to theme all your components using css. It's native meaning no web views and what not AND its fairly easy to implement in an existing project. Check it out.

Workflow for parsing PSD to Xcode/IB

i am searching for a way to parse a psd-layout to a nib-file or something like this. I want, that the designer builds a layout and slices this into the different elements. The result should be a ready-to-use XIB-File. ;-)
Are there any ideas how to realize this?
Thanks
You can ask your designer to name the difference slices using a specific nomenclature.
A possibility:
specific_name-class-x-y-width-height
e.g.
LoginButton-UIButton-60-200-120-40
Then a script parsing each file of your export folder will create your xib file which is nothing more than a XML file.
a simple way to do that could be using psd.js
But I think that it will be much simpler to teach your designer how to use Interface Builder ;)
I've heard about snippets (.jsx = javaScript??) which you can use for Photoshop. These scripts could export your images/layer/slices and change the name to their relative position. Maybe this information could be helpful for anybody.
This tutorial explains exactly how to automatically port a Photoshop PSD or Fireworks Layered PNG into an Xcode storyboard. With all your elements placed for you. http://www.youtube.com/watch?v=hB5PJgIrUko&sns=em
write your own photoshop script:
http://www.adobe.com/devnet/photoshop/scripting.html
or, use this service:
http://www.psdtoxib.com/

Can we create xib (with view) programmatically ? If No, why & If yes, How?

Can we create xib (with view) programmatically ? If No, why & If yes, How ??
Xibs are just files, too, so there's no technical reason why you wouldn't be able to create one programmatically.
Expect no convenience methods to create xibs however, as their purpose is to circumvent the need to create and configure UI elements programmatically, so what you would like to do is exactly the opposite of what people normally use xibs for.
If you really must create xibs though, just open one in a texteditor - you'll see that it consists of readable xml code. It may take some time to work through all the keys and possibilities, but creating xibs programmatically can be done.
Edit: it's gonna be hard, though.

Is it possible to directly edit the XML of XIB files?

I tried to do it, but Interface Builder refuses to open the resulting file:
alt text http://img81.imageshack.us/img81/7194/screenshot20091102at252.png
"Interface Builder was unable to determine the type of [file name]"
To answer your question (as you put it in the title): Yes, it is. I did it with TextWrangler for a test (moved a widget) and it works like a charm.
I suspect, you also changed something else (encoding, file name) when you were editing the file. You should try it again with a copy of the xib and do a diff between original and result.
It is possible. Just the task's complexity is approaching the complexity of writing an web app in assembler.
Joking. It's highly not recommended. I think this Xib is not your and Interface builder is just not allowing you to use it.
While the XML format of XIB files is intended to be somewhat human readable, XIB files should never be edited by hand. While the file may appear mergable, the object graph is complex and cannot be maintained except when edited within Interface Builder.
Even if it appears to work, this is unsupported and could lead to more complex problems down the road. It is better to instead file enhancement requests on Interface Builder to provide the capability you need, rather than try to hand edit the XML.

Template declaration to dynamically find views in RoR

I'm trying to separate the views for the different platforms into different subfolders.
I have done this for the layout, at the moment I have the following:
class MoviesController < ApplicationController
layout :site_layout
def site_layout
if(iphone_request?)
"iPhone/movies"
else
"movies"
end
This means that in my action methods I don't need to include :layout, however I do still need to manually include the path to the template.
format.iphone {render :template => 'movies/iPhone/index'}
Is there a way to have the same kind of layout declaration but for templates?
Thanks
Ben
You may want to extend the view_paths so that you can have a special iphone subfolder under views and override templates as necessary. See this tutorial on how to do that.
However, is there a reason you don't want to use the iphone format in the view name (show.iphone.erb) instead of making a subfolder? See martinkl's answer in your other question for details.
I might be off, but maybe it'll help - try checking prepend_view_path.