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?
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.
Comments