简体   繁体   中英

iphone - Interface Builder not loading custom class?

I generally don't use Interface Builder (I hate it). But I am being forced to use it, because I was invited to a project where people are using it. I am trying to create a custom UISlider.

I have created a UISlider custom class, with my own images for the slider parts.

If I add a new object to my main code using

mySlider *one = [[mySlider alloc] initWithFrame:CGRectMake(0,0,60,30)];

I see the slider as I created, beautifully.

But if I use this class on interface builder, to change the appearance of a UISlider I create there, the slider continues to have the same appearance as before and when I run the app the interface shows the slider with the default appearance, not the one I designed.

I created the slider on IB, simply dragging a UISlider on the interface and changing its class to the one I've created. Is there something else that has to be done? Why is it not showing as defined on the custom class?

thanks

You need to implement the initWithCoder: initializer. initWithFrame: will not be called when a nib is loaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM