Protocols & Delegate when using ContainerView

NoUser

I have a UIViewController (root) with a ContainerView that loads a nib programatically:

UIView *containerView = [[[NSBundle mainBundle] loadNibNamed:@"KeyboardView" 
    owner:self options:nil] objectAtIndex:0];

[self.view addSubview:containerView];

I have a class file (.h and .m) hooked to this .xib file (UIView).
My .xib file (UIView) has a button and an action.

When this action is invoked and executed I removeFromParent my .xib file.

How can my ViewController.m (root) handle the exact time I removeFromParent my nib file?

I tried to use Protocol & Delegate but it failed.
I tried to set delegate=self on prepareForSegue Method but was unsuccessful.

My question is:
My UIViewController (root) invokes my keyboard (.xib) programatically.
All action in my keyboard are handled by the class hooked to the .xib.
After action’s job is done I removeFromParent the .nib file (I simulate a dismiss).

How can methods in ViewController.m (root) know that I dismissed my .xib file?

Jeffery Thomas

I'm not exactly sure what you are doing here, but I think I understand your question.

In your interface, declare a weak property for the keyboard view.

@property (weak, nonatomic) UIView *keyboardView;

Then when you load the keyboard

UIView *containerView = [[[NSBundle mainBundle] loadNibNamed:@"KeyboardView" 
    owner:self options:nil] objectAtIndex:0];

[self.view addSubview:containerView];
self.keyboardView = containerView;

Now you can test self.keyboardView != nil to know if the keyboard is loaded.

This works because keyboardView is weak so when it's removed from it's parent view the property will be set to nil.


NOTE: No protocol or delegate is needed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

using <ProtocolName> when creating protocols

From Dev

using <ProtocolName> when creating protocols

From Dev

How to be notified when a UINavigation is dismissed using protocols?

From Dev

Create or not a protocol when using delegate

From Dev

Setting the delegate when using canDisplayBannerAds

From Dev

Trigger viewWillAppear when using a transitioning delegate

From Dev

Selecting specific elements when using the body as the delegate

From Dev

Pins have disappeared when using MKAnnotationView delegate

From Dev

"object reference not set to an instance" when using delegate

From Dev

Interface Builder, @IBOutlet and protocols for delegate and dataSource in Swift

From Dev

protocols delegate methods not calling properly in ios

From Dev

Headerdoc with delegate Protocols - Swift and xcode 7.2

From Dev

Using protocols to pass data

From Dev

Using Swift protocols with generics

From Dev

TableView not showing data in ContainerView using Xcode 7

From Dev

CALayer delegate is only called occasionally, when using Swift

From Dev

error when using parse functions outside of the app delegate

From Dev

How to get visible viewController from app delegate when using storyboard?

From Dev

Affdex AFDXDetector delegate functions are never called when using the camera?

From Dev

Getting an error when using EclEmma (eclipse plugin) with JMockit (only with Delegate())

From Dev

How to get Inbox of a delegate mailbox when using 2007 PIA

From Dev

CALayer delegate is only called occasionally, when using Swift

From Dev

Issues when inserting multiple rows into a tableView using NSFetchedResultsController delegate methods

From Dev

Using generic protocols in generic classes

From Dev

Using LineReciever with Twisted Process protocols

From Dev

Python Syntax error using protocols

From Dev

Should I Be Using Protocols for these Models?

From Dev

Delegate when constraints updated

From Dev

How to remove UITableView top inset when embedded in ContainerView?

Related Related

  1. 1

    using <ProtocolName> when creating protocols

  2. 2

    using <ProtocolName> when creating protocols

  3. 3

    How to be notified when a UINavigation is dismissed using protocols?

  4. 4

    Create or not a protocol when using delegate

  5. 5

    Setting the delegate when using canDisplayBannerAds

  6. 6

    Trigger viewWillAppear when using a transitioning delegate

  7. 7

    Selecting specific elements when using the body as the delegate

  8. 8

    Pins have disappeared when using MKAnnotationView delegate

  9. 9

    "object reference not set to an instance" when using delegate

  10. 10

    Interface Builder, @IBOutlet and protocols for delegate and dataSource in Swift

  11. 11

    protocols delegate methods not calling properly in ios

  12. 12

    Headerdoc with delegate Protocols - Swift and xcode 7.2

  13. 13

    Using protocols to pass data

  14. 14

    Using Swift protocols with generics

  15. 15

    TableView not showing data in ContainerView using Xcode 7

  16. 16

    CALayer delegate is only called occasionally, when using Swift

  17. 17

    error when using parse functions outside of the app delegate

  18. 18

    How to get visible viewController from app delegate when using storyboard?

  19. 19

    Affdex AFDXDetector delegate functions are never called when using the camera?

  20. 20

    Getting an error when using EclEmma (eclipse plugin) with JMockit (only with Delegate())

  21. 21

    How to get Inbox of a delegate mailbox when using 2007 PIA

  22. 22

    CALayer delegate is only called occasionally, when using Swift

  23. 23

    Issues when inserting multiple rows into a tableView using NSFetchedResultsController delegate methods

  24. 24

    Using generic protocols in generic classes

  25. 25

    Using LineReciever with Twisted Process protocols

  26. 26

    Python Syntax error using protocols

  27. 27

    Should I Be Using Protocols for these Models?

  28. 28

    Delegate when constraints updated

  29. 29

    How to remove UITableView top inset when embedded in ContainerView?

HotTag

Archive