Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3403920
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:19:09+00:00 2026-05-18T05:19:09+00:00

I have a View Controller calling a method in its own view called closeMenu.

  • 0

I have a View Controller calling a method in its own view called closeMenu. closeMenu as seen below remove’s a UIImageView called menu from the superView and sets it equal to nil. The method works when called from within the view but not when called from the View Controller

When calling the method, the view controller sees the UIImageView ‘menu’ as nil even though it is exists.

Any ideas on how to give the view controller the ability to remove menu from the superview and set it equal to nil?

View Controller:

     loadview {
        View *mainView = [[View alloc] initWithFrame:CGRectMake(0,0,320,480)];
        self.view = mainView;
        [mainView release];
     }

//Call closeMenu in View
[(View *)self.view closeMenu];

View:

menu = [[UIImageView alloc] initWithImage:image];
[self addSubview:menu];

-(void)closeMenu {
     NSLog(@"%@", menu);    //Displays: (null), only when called by controller
     if( menu != nil) {
           [menu removeFromSuperview];
           self.menu = nil;
     }
 }

When I create a button instance in the view with an action directed at the closeMenu method it works just fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:19:10+00:00Added an answer on May 18, 2026 at 5:19 am

    Is menu an outlet? If so, is it hooked up in IB? Have you loaded the nib where it’s hooked up?

    If not, where are you assigning to it? Is the controller giving the view its menu? If that’s the case, has that happened yet? If the view creates or loads its own menu view, has that happened yet, if at all?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have referred http://bakery.cakephp.org/articles/view/calling-controller-actions-from-cron-and-the-command-line and created cron_dispatcher.php and placed it in the app folder.
My modal view controller is not calling its dealloc method when it dismisses itself.
When submitting one form from view, how can i also read or have controller
I have controller method in my MVC application that I am calling using the
I have two test method calling to controller: This one passed: [Test] public void
Lets say I have a view, myView, a view controller, myViewController, and some sort
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
We have a View (call it X) that is the base view called by
I have a model with a reference to the view, a controller with references

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.