1
votes

I use xib to create my custom view, and i bounded it with the same name .h .m file. I set the custom view class to UIView's class in storyboard , but it didn't work.

my custom view

enter image description here

I drag a UIView

enter image description here

1
you have to add one UIView in StoriBoard right?Vvk
IB will render a live preview of UIView subclasses if they implement @IBDesignablePaulw11

1 Answers

1
votes

Step 1 :

Create a Xib (your View) file, then create your.h and .m files,

If you already have a viewcontroller that will use the xib: implements everything in it.

Step 2 :

Open your Xib file, in the interface builder you will find on the left : File's owner, select it and then, on the right in the identity inspector tab, add your custom class.

Step 3 :

import your xib class in your.h file

Now you can create IBOUTLET in your.h file.

Step 4 :

To get the xib in your.m just write something like this -->

in viewDidLoad:(or everywhere you need it)

NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"RunningMode_VC_Interface" owner:self options:nil];
runningViewXib = [subviewArray objectAtIndex:0];
runningViewXib.frame = self.view.frame;
[self.view addSubview:runningViewXib];

You will now add your custom view to your viewcontroller. Then create your custom interface/functionality methods to work easy on it.

hope it helps.