Inherit from Custom UiViewController with xib

lufo88lufo88 USMember ✭✭✭

Hi,

I created a custom UIViewController (MyCustomController) that has a xib in the storyboard of my app.

I want to achieve this result:
MyCustomController has his own xib in story board. Declare this class as abstract and declare a method as

protected abstract void DoSomething();

SubControlleA inherit from MyCustomController implements DoSomething and nothing else.
SubControlleB inherit from MyCustomController implements DoSomething and nothing else.

Is it possible? Can I use SubControlleA and SubControlleB in the storyboard?

Posts

  • JoeProJoePro CAUniversity ✭✭✭
    edited July 2017

    If you decorate those custom controllers with the Register Attribute, they'll be accessible in Xcode. Then, it's just a matter of changing the type from UIViewController to your custom controller type in the drop down. Sorry, I'm not familiar with the iOS designer, but it should be fairly similar I think.

  • lakhanimilan91lakhanimilan91 INMember ✭✭

    Hi @lufo88 ,

    You can achieve the same by using Register Attribute available in FOundation namespace.
    Once you can set the attribute above your class name. You can see the class name suggestions in attribute inspector in xcode storyboard.

    You can add multiple xibs for the same and can change class name.

    hope this will help.

    Thanks,

  • lufo88lufo88 USMember ✭✭✭

    I need to test this approach. I update this thread as soon as possible.
    Thank you.

Sign In or Register to comment.