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 8341865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:36:38+00:00 2026-06-09T05:36:38+00:00

I am attempting to dismiss a popover as well as return a variable when

  • 0

I am attempting to dismiss a popover as well as return a variable when a button is clicked in the popover. There are four buttons and on selection of a button, the variable (based on the button) will be returned to the original view controller and the popover will close. I am unsure of how to attempt the passing of the variable, but I am attempting to at least do the popover close on button click using this page (http://stackoverflow.com/questions/3565968/dismiss-popover-using-uibutton), which for some reason doesn’t work for me. When I click on the button absolutely nothing happens.

AddWineViewController is the “root” view controller

//AddWineViewController.h
//this is the "root" view controller
#import "WineStyleViewController.h"
@interface AddWineViewController : UIViewController <UIPopoverControllerDelegate, MyPopoverDelegate>
@property (nonatomic, retain) UIPopoverController *myPopoverController;

 

//AddWineViewController.m
@implementation AddWineViewController
@synthesize myPopoverController;
-(void)didClickCancelButton {
    //I would like to have the variable passed here, something like self.wineStyle.text=wineStyle; where wineStyle is the variable from the popover.
    [myPopoverController dismissPopoverAnimated:YES];
}

WineStyleViewController is the popover view controller

//WineStyleViewController.h
@protocol MyPopoverDelegate <NSObject>
    -(void)didClickCancelButton;
@end
@interface WineStyleViewController : UIViewController
@property (nonatomic, assign) id<MyPopoverDelegate> delegate; 
@property (nonatomic, strong) NSString *wineStyle;
- (IBAction)redWineButton:(id)sender;

 

//WineStyleViewController.m
@implementation WineStyleViewController
@synthesize wineStyle;
@synthesize delegate;

- (IBAction)redWineButton:(id)sender {
    wineStyle=@"Red";
    [self.delegate didClickCancelButton];
}
  • 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-09T05:36:39+00:00Added an answer on June 9, 2026 at 5:36 am

    I’ll make a few assumptions first, being that all of your connections in your storyboard are connected, and all objects are properly created, and that you have set delegate to self in your segue.

    Just to be certain … make sure your segue includes:

    // set your destination view controller
    WineStyleViewController *destinationController = segue.destinationViewController;
    destinationController.delegate=self;
    

    In your delegate (popover): WineStyleViewController, you define your protocol as:

    @protocol MyPopoverDelegate <NSObject>
        -(void)didClickCancelButton;
    @end
    

    but you want to pass back the wineStyle to the root controller (AddWineViewController) so you need to
    1) add the variable (wineStyle) to pass back and 2) pass along your delegate’s ViewController (I took the liberty to change to Save instead of cancel)

    @protocol MyPopoverDelegate <NSObject>
    -(void)didClickSaveButton (WineStyleViewController *)wineStyleViewController withWineStyle (NSString *)wineStyle;
    @end
    

    Now going back to AddWineViewController:

    your -(void)didClickCancelButton:(WineStyle)wineStyle is where you will receive from your delegate your wine style, so this method should look more like: (again changing it save)

    -(void)didSave
    {
        // your methods for dealing with your added wineStyle go hear, as
        // you will already have wineStyle sent back to you from your delegate
        [myPopoverController dismissPopoverAnimated:YES];
    } 
    

    hope that helps 😀

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

Sidebar

Related Questions

Attempting to make a NSObject called 'Person' that will hold the login details for
Attempting to run a MIB based SNMP script and I running into an issue.
I'm attempting to create a Please wait UIAlertView that will appear while my code
Attempting something like public string MyText { get {return lbl.Text;} set {lbl.Text = value;}}
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Attempting to set up an automated texting service for customers, where people can text
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to implement a poor man's test of whether a process is still running
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng

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.