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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:51:45+00:00 2026-05-18T06:51:45+00:00

I have a UITabBar application, which has three tabs. The first tab has a

  • 0

I have a UITabBar application, which has three tabs. The first tab has a UIViewController with a UIButton which displays a modal UIViewController to allow the user to select a date. I’m having trouble updating the label of the UIButton when the user has selected their chosen date.

My Main View Controller .h / .m

#import <UIKit/UIKit.h>

@interface SearchViewController : UIViewController {
    IBOutlet UIButton *butFromDate;
}

@property (nonatomic, retain) UIButton *butFromDate;

- (IBAction)pickDate:(id)sender;

@end

////////////////////////////////////////////

#import "SearchViewController.h"
#import "SearchDatePickerViewController.h"

@implementation SearchViewController

@synthesize butFromDate;

- (IBAction)pickDate:(id)sender{
    SearchDatePickerViewController *sampleView = [[[SearchDatePickerViewController alloc] init] autorelease];

    [sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentModalViewController:sampleView animated:YES];
}

- (void)dealloc {
    [butFromDate release];
    [super dealloc];
}

@end

Then my modal window (with a UIPicker, and a couple of UIBarButtons to cancel or save the user’s choice) .h / .m looks like:

#import <UIKit/UIKit.h>

@interface SearchDatePickerViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {
    NSMutableArray *dates;
    IBOutlet UIPickerView *picker;
}

@property (nonatomic, retain) NSMutableArray *dates;
@property (nonatomic, retain) UIPickerView *picker;

- (IBAction)cancelDatePick:(id)sender;
- (IBAction)pickDate:(id)sender;

@end

////////////////////////////////////////////

#import "SearchDatePickerViewController.h"
#import "SearchViewController.h"
#import "AppDelegate.h"
#import "Search.h"

@implementation SearchDatePickerViewController

@synthesize dates, picker;

- (IBAction)cancelDatePick:(id)sender{
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)pickDate:(id)sender{
    HolidayCottagesAppDelegate *appDelegate = (HolidayCottagesAppDelegate *)[[UIApplication sharedApplication] delegate];
    SearchViewController *searchView = [SearchViewController alloc];
    appDelegate.currentSearch.fromDate = [dates objectAtIndex:[picker selectedRowInComponent:0]];

    [searchView.butFromDate setTitle:@"HELLO-TEST" forState:UIControlStateNormal];
    [self dismissModalViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    NSDate* curDate = [NSDate date];
    NSCalendar* calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents* comps = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekCalendarUnit|NSWeekdayCalendarUnit fromDate:curDate];
    NSTimeZone* gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
    dates = [[NSMutableArray alloc] init];

    [comps setTimeZone:gmt];
    [comps setWeekday:7];

    int startCount = comps.week + 1;
    int endCount = (((52 - startCount) + 52) + startCount);

    for (startCount; startCount <= endCount; startCount++){
        NSDate *tDate = [calendar dateFromComponents:comps];
        [dates addObject:tDate];
        [comps setWeek:startCount];
    }
}

// OTHER SHIZZLE HERE BUT NOT REALLY NEEDED TO DISPLAY...

So, when I click the Save button, it runs -(void)pickDate: all ok and dismisses the modal view, but it won’t update the SearchViewController’s UIButton label to “HELLO-TEST”. I’m sure I’m missing something simple here…

Please help me!!

Thanks 🙂

  • 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-18T06:51:46+00:00Added an answer on May 18, 2026 at 6:51 am

    In your main view controller, you need to pass a “self” reference to the search date picker view controller, and then set up an ivar for the main view controller in the search date picker view and use that reference in the pickDate method of the search date picker view. Please check out a blog entry of mine from last year on this exact subject:

    http://www.dosomethinghere.com/2009/10/04/passing-values-and-messages-between-views-on-iphone/

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

Sidebar

Related Questions

I have a UITabBar + UINavigationController application which often needs data from the internet.
I created a window application, which has a tabbar controller with four tabbar items.
I build my first iPhone application and I have a problem with switching views.
quick question - I have my first view which is going to be the
I'm developing an iPhone application which uses a TableView to display XML data. The
I have this problem, I've got a navigation-based application, and on the one of
I have created an UITabView application. Each view selected from the bar is a
I'm currently developing a simple iPhone application using a UITabBar and table views for
(By the way, I don't use Interface Builder) I have a little project consisting
I am using keyboardWasShown and keyboardWillBeHidden notification for sliding the view to get the

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.