Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set an UIView subclass from a framework as a storyboard custom class?

I have an UIScrollView subclass defined in an external framework. If I create instances of this class in code, it works as expected. If I try to set this class as a custom class on an UIScrollView in Scoryboard, it's not listed in available custom classes. If I set it, when I check the object's class it's an UIScrollView (so it doesn't allow to call methods of the subclass).

This happens in a Swift 2.0 project targetting iOS 8.1 (Xcode7) The framework is using Swift 2.0 too and targetting iOS 8.0 The framework is included manually in the project (copy paste + add to Embedded Binaries)

Hope it's clear enough :D

like image 500
PeYoTlL Avatar asked Sep 17 '15 03:09

PeYoTlL


People also ask

How to create custom UIView Swift?

Open Xcode ▸ File ▸ New ▸ File ▸ Cocoa Touch class ▸ Add your class name ▸ Select UIView or subclass of UIView under Subclass of ▸ Select language ▸ Next ▸ Select target ▸ Create the source file under your project directory. Programatically create subviews, layout and design your custom view as per requirement.

What is the base class of UIView?

The UIView class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content.

What is a UI view?

A uiview is a viewport component provided by UI-Router. When a state is activated, the state's view (component) is rendered into the appropriate uiview viewport. When an app renders a uiview , it becomes a viewport for views (components) to be loaded into.


1 Answers

You must specify a module together with class.

In this example we use class MyCustomScrollView from the framework MyScrollViews.framework.

enter image description here

like image 122
Vladimir Prudnikov Avatar answered Nov 15 '22 06:11

Vladimir Prudnikov