Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is not working because you are sending removeFromSuperview to the wrong view object. This is what you need:</p> <pre><code>[medicalViewObject.view removeFromSuperview]; </code></pre> <p>EDIT:</p> <p>Your question suggests that you have a view (because you did not include the name of this view in your question, I will simply call it MainView) and then you add a subview called medicalViewObject to your MainView. You also have a method call "BackToMainView" which you want to perform the removeFromSuperview function. Your question suggests that some user action in your medicalViewObject (such as a button press) is supposed to call the "BackToMainView" method.</p> <p>If this is all correct, then my answer above is correct. But based upon your comment, it sounds like you will also need to implement a delegate protocol in your medicalViewObject, and then have your "MainView" adopt the protocol.</p> <p>In your declaration of the delegate in your medicalViewObject, you need to have a method call like this:</p> <pre><code>-(void)backButtonWasPressed; </code></pre> <p>and in the implementation of your MainView it should look something like this:</p> <pre><code>-(void)backButtonWasPressed { [medicalViewObject.view removeFromSuperview]; } </code></pre> <p>So now, whatever user action you are using in your medicalViewObject to go back to the main view (whether a button or some other object) it needs to call the following:</p> <pre><code>[delegate backButtonWasPressed]; </code></pre> <p>Depending on your situation it may look a little different, but this a fairly common way to accomplish what you are trying to do. I hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload