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

  • SEARCH
  • Home
  • 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 9228961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:27:20+00:00 2026-06-18T05:27:20+00:00

I have a view controller with an image view in it. I have a

  • 0

I have a view controller with an image view in it.

I have a popover with a table view in it which is anchored to a bar button in this view controller.

I would like to be able to load images into the image view by using the table in the popover.

Both the popover and the main view controller have separate view controller classes.

I have launched the popover from a segue.

How can I do this?

  • 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-06-18T05:27:21+00:00Added an answer on June 18, 2026 at 5:27 am

    I am assuming that your segue takes you from your imageViewController to your popped-over tableViewController.

    Then you can set your imageViewController as delegate to the tableViewController, so that you can call methods on it from the tableViewController in a decoupled manner.

    MyTableViewController.h

    In your tableViewController header file declare a protocol which it will expect it’s delegate to follow. Place it above your @interface section:

        @protocol MyTableViewControllerDelegate <NSObject>
        - (void) dismissPopoverAndLoadImage:(NSString*)imageName;
        @end
    

    Also declare a property to hold a reference to it’s delegate:

      @property (nonatomic, weak) id <MyTableViewControllerDelegate> delegate;
    

    The protocol declares the method signature that your tableView will expect to be able to call on its delegate. It allows it to send back some data, and get itself dismissed. The delegate (in this case, your imageViewController) will have to implement this method.

    MyTableViewController.m

    The method is called on the delegate when a table cell is selected:

        - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
        {
           UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
           NSString* imageName = cell.textLabel.text;
           [self.delegate dismissPopoverAndLoadImage:imageName];
        }
    

    MyImageViewController.h

    include MyTableViewController.h and add the delegate protocol to the @interface.

    #include "TableViewController.h
    
    @interface MyImageViewController: UIViewController <MyTableViewControllerDelegate>
    

    Declare a property to hold a reference to your UIPopOverController so that you can send it a dismiss message:

    @property (nonatomic, weak) UIPopoverController* seguePopoverController;
    

    (these steps could be moved to your .m file’s category extension for better encapsulation).

    MyImageViewController.m

    You will set the delegate property in MyImageViewController‘s prepareForSegue method, which gets called when the segue is invoked.You will also set the reference to the popoverController here.

    - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([segue.identifier isEqualToString:@"popoverTable"]) {
            self.seguePopoverController = [(UIStoryboardPopoverSegue*)segue popoverController];
            [segue.destinationViewController setDelegate:self];
            }
        }
    } 
    

    Lastly, you implement the tableViewController’s delegate method:

    - (void) dismissPopoverAndLoadImage:(NSString*)imageName
    {
        self.imageView.image = [UIImage imageNamed:imageName];
        [self.seguePopoverController dismissPopoverAnimated:YES];
    }
    

    update
    Aside from the fact that the popOverController itself is a slightly unusual entity (a controller without a view, inheriting directly from NSObject), most of this is the standard delegation pattern. You could simplify it somewhat by using a bit of indirection and runtime checking in didSelectRowAtIndexPath:

     if ([[self delegate] respondsToSelector:@selector(dismissPopoverAndLoadImage:)])
           [[self delegate] performSelector:@selector(dismissPopoverAndLoadImage:)
                                 withObject:imageName];
    

    In this case you would not need to define the protocol or <adhere> to it, and you wouldn’t need to #import MyTableViewController. However the compiler would give you no help if you did not implement the method correctly. Which, as you can see from my earlier mistake, is probably unwise.

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

Sidebar

Related Questions

i have view controller which contains a button which show the image library ,if
I would like to have a view controller that loops an image in the
I have a view controller that I would like to present in a modal
I have a UI Table View Controller. Each Cell Loads an image from my
I am designing an application in which i have a table view controller. Now
I have view controller, into the view i have put a table view, and
I have a View controller displaying some information (not table views). I have an
In my app i have an image view in one view controller and a
I have a table view with 10 cells displaying an image. Everytime I scroll,
I have one view controller in which I have added UIScrollView & UIImageView programatically.

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.