ios - UIView in a ViewController using swift -


I have a custom view (.xib and .swift) and I use it in different view controllers and custom cellviewviews Want to . I do not know how to do this: p. How can anyone help me in accomplishing this?

My custom view is a restaurant, I have labels and images: `Look at the Restaurant Category: UIView {

  @Iboutlet var View: UIView! @Ibotlett Weak Verge Imaglogo: UIImageView! @IbotletWorldVar IMGrating: UIImageView! @IBOOTlet Weak var lblName: UILBL! @IBOutlet weak var lbl Comments: UILBL! @IBOOTlet Weak var lbl minimum order: UILBL! @IBOutlet weak var lbl deliveryCost: UILBL! @Iibotlet Weakly Worli Blackstats: UILball! / * // Only Override Direct: If you do custom drawing // An empty implementation adversely affects performance during animation Override Funk Direct (Rect: CGRTact) {// drawing code} * /   

} `

I want to put it in the restaurant view controller:

Restaurant viewer of the range: UIViewController { @IBOutlet Weak Wear Restaurant: Restaurant View! Override func viewDidLoad () {super.viewDidLoad () subviewArray = NSBundle.mainBundle (). LoadNibNamed ("RestaurantView", owner: self, option: zero) View filter: RestaurantView = subviewArray [0] as RestaurantView self.view.addSubview (FilterView) // Setup an additional after loading the view}

`

But when I run the app, it crashes when it is showing the message:

* Reasons for the disapproval exception Ending the app 'NSUnknownKeyException', Reason: '[setValue: forUndefinedKey:]: The key value for this class key imgLogo is not coding-compliant.' * First Focus Call Stack:

etc ....

Each scene should have the owner, assume that you create a subview of UIVUV named CustomView. Then you created the Xib file with the same name.

1) Enter in your EXIF ​​file, select the top view, and set the customview class in the Identification Inspector. Now, the scene will be linked to your custom swift file in your Xib file.

2) To make this scene instantly, you need a master for the scene. In most cases, the owner is a view controller, therefore, you can use this snippet in your view controller:

  two subviewArray = NSBundle.mainBundle (). LoadNibNamed ("CustomView", Owner: Self, Option: Zero) Filter: View CustomView = subviewArray [0] as CustomView self.view.addSubview (filterView)   

Hope It helps!

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -