Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

namanhams

macrumors regular
Original poster
Jun 3, 2009
153
0
Hi,

I've define a custom UIView in a NIB file. I can use it programmatically by loading from NIB file. My question is : is there any way i can use my custom view in IB ? It would be easier to layout everything by IB than by hard coding.
 
not gettings it ... if you have your custom view in a NIB file, then you just open that and it goes straight to interface builder, doesn't it?
 
Unfortunately no. For Mac apps it is possible to write a plugin that allows you to edit custom views directly in IB. This isn't available for iPhone apps at this time.
 
you can create a view and then tell it that it is a custom view.

so for example, you write a custom UIView subclass called "MyView". then you create a view in IB and then you can tell it that it is a "MyView" instead of a "UIView".

that works, if that is what you want. it can be done in IB, by selecting the view, then going to the "View Identity" window (info-button in the view's properties window) and then just enter your custom classname in "Class Identity"
 
@BlackWolf : yes i do this way. But actually it's still a bit inconvenient, since it's not visual at all. I can just change the identity to my custom class, but the custom view still appears as a white rectangle, and i have to manually change the size. Let's say later i change the size of my custom view, then i also need to change everywhere i use it.
But i think it's the only way.
Anw, thanks all for your replies.
 
@BlackWolf : yes i do this way. But actually it's still a bit inconvenient, since it's not visual at all. I can just change the identity to my custom class, but the custom view still appears as a white rectangle, and i have to manually change the size. Let's say later i change the size of my custom view, then i also need to change everywhere i use it.
But i think it's the only way.
Anw, thanks all for your replies.

aaah, i see what you mean.
yeah, that's true.

but if you are following the logic completly, you should change the size in IB and not programatically. of course, sometimes that's maybe not what you want, but if I create a view in interface builder I do as much as possible in IB, so if for example I change the size of the view I don't need to do anything in xcode.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.