Search code examples
iphoneiosios5ios6

calling [self removeFromSuperview]; from subview doesnot give back control to parent view


I have created a custom popUp view using UI view.This popupview contains a button and image.

My parent view (with controller) contains a button.On button click, i am adding popup view as subview(see below) -

[self.view addSubview:popUp];

In my popup view i have handled the click of button as below -

- (IBAction)tapHabitatureButton:(id)sender {   
   [self removeFromSuperview];
}

So on click of popup button,i close my popup.

After my popup get close i can see my parent view. But now my parent view no longer interacts to events.

Please help me with the solution.


Solution

  • Use [popUP removeFromSuperview ] instead of [self removeFromSuperview]

    Well here i am providing what you need to do 1. Make instance of your popUP View Suppose popUP *view = [popUP alloc]init]; or create it via IBOUTlet Then add it as you are doing while removing popUP (UIView) from itself take advantage of delegate create protocol in your popUP class that inherits UIView and implement it in your SuperView

    Then use in that function [popUP removeFromSuperview ] means remove your popUP instance from superview, You need all that.