iOS Popover Calendar View

iOS Popover Calendar View

Released 5 years ago , Last update 5 years ago

Popover Calendar View is a popover calendar view with markable and selectable dates, a popover text menu and a custom popover for general needs. This package includes full source code and a working demo.

UIPopoverCalendarView is a class for creating a popover view containing an advanced calendar with marked dates, basic calendar or text menus. For iPad, iPhone and iPod Touch.

Advanced calendar supports marked dates which are underlined in your desired color. Differentiation between clicking marked and regular dates allow for processing key dates. Marked dates supplied can be any dates you desire and the calendar will automatically mark dates for the calendar month.

Easy to use, simple, clean and animated

Adjustable animation speed and customization.

Easy Popover Creation

Static factory methods allow you to easily create advanced, basic and text based popover views in your app. Instance methods allow for increased flexibility and access to popover, calendar and text.

Calendar in popover selection causes callback to your application for date change, month change, date selection, marked date selection and popover dismissal.

View in popover selection causes callback to your application for view selection and popover dismissal.

Text menu popover selection causes callback to your application for text menu selection and popover dismissal.

Popover view can be automatically dismissed when selected or can stay visible.

Some Uses

  • create a popover with an advanced calendar showing current date, mark dates of importance and specific mark underline color, go to previous or next month, date selection for marked and unmarked dates.

  • create a popover with an basic calendar showing current date, previous month, next month but for view-only use.

  • create a popover menu with selectable text menu items.

  • create a popover view with your own specified selectable UIView.

  • create other types of popover view to suite your needs using included classes.

  • many dates tools for processing and using dates.

iOS Support

This project supports iOS 7, iOS 8, iOS 9 and iOS 10.

2.0
  • 5 0
  • 4 0
  • 3 1
  • 2 0
  • 1 1
2 Reviews Read Reviews

Pricing

14 day 14-day money-back guarantee

$9.99

Single App

  • Perpetual license

  • 1 application

  • Can distribute binary products only

  • Commercial use

  • 1 month support

$49.99

Developer

  • Perpetual license

  • Unlimited projects

  • Can distribute code and binary products

  • Commercial use

  • 12 months support

Need custom services for this product? Get a quote

Supported OS & SDK Versions

  • Supported build target - iOS 6.0, iOS 7, iOS 8, iOS 9 and iOS 10 / Mac OS 10.7 (Xcode 4.3.1, Apple LLVM compiler 3.1)
  • Earliest supported deployment target - iOS 6.0 / Mac OS 10.6
  • Earliest compatible deployment target - iOS 6.0 / Mac OS 10.6

NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.

Installation

To install UIPopoverCalendarView into your app, create a UIPopoverCalendarView folder in your project then drag the files in the UIPopoverCalendarViewDemo project UIPopoverCalendarView folder to the created folder. Make sure that you indicate to copy the files into your project. Also make sure that the Target Membership is checked for all .m source files and non .h files.

Usage

To use this class, you must link against the following frameworks:

  - CoreGraphics
  - Foundation
  - UIKit

// see Demo Example in Examples/Demo folder for full source code

// dates to mark is an array of dates to mark on the calendar.   
// marked dates are underlined in marked dates colors specified below.
NSArray * _markedDates = [[NSArray alloc] initWithObjects:  [NSDate date], [[NSDate date] dateByAddingDays:-4], [[NSDate date] dateByAddingDays:-3],  [[NSDate date] dateByAddingDays:-2], nil];

// color to use to mark dates.  If null default red color used 
// Note: if specify marked colors, then must have a color for each date.
NSArray * _markedDateColors = [[NSArray alloc] initWithObjects:[UIColor whiteColor], [UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];
// NSArray * _markedDateColors = nil;  // this uses default marked (underline) color of red

// example showing popover calendar view from a view (button) point in a view....
// you can replace "_button" with any view within the main 'inView'
UIPopoverCalendarView * popoverView =   [UIPopoverCalendarView showAdvancedPopoverCalendar:_button inView:self.view markedDates:_markedDates markedDateColors:_markedDateColors delegate:self];
[popoverView setDismissAfterSelection:TRUE];    // keep popover displayed even after selection (tap in open area still closes popover)
                                            // if dismiss after selection is off, the calendar will stayed displayed and allow for selections until user closes by clicking on an open area of the screen
[popoverView setDismissAfterSelectionDuration:0.1];   // if dismiss after selection is on, the dismiss animation duration

// callbacks (delegate)
//
// called when advanced calendar switches to another month 
- (void)popoverCalendarView:(UIPopoverCalendarView *)popoverCalendar calendarView:(CalendarView *)calendarView switchedToMonth:(int)month year:(int)year {

NSLog(@"%s switched to the month %d...", __PRETTY_FUNCTION__, month);

}

// called when advanced calendar date, marked or non-marked, is selected.
//
//  popoverCalendar is the associated UIPopoverCalendarView object
//  calendarView is the associated CalendarView object shown in the popover
//  isMarked flag indicates if date selected is a marked date
//  isToday indicates if date selected is today
//  
- (void)popoverCalendarView:(UIPopoverCalendarView *)popoverCalendar calendarView:(CalendarView *)calendarView dateSelected:(NSDate *)date marked:(BOOL)isMarked today:(BOOL)isToday {

NSString * _dateStr = [popoverCalendar formatDate:date];

//NSLog(@"%s selected the date %@...", __PRETTY_FUNCTION__, _dateStr);

// Note: if a date is marked then you can treat it a special way.
//       if a date is not marked you can ignore the date or doing some processing for non marked dates
//
// Usually marked dates on the calendar are significant and are the dates to process.
// e.g. if you mark just dates that have you have photos for and then when a user selects
// the marked date you show photos for that date...
//
NSString * _msg = nil;

if (isMarked) {

    if (isToday)
        _msg = [NSString stringWithFormat:@"The marked date %@ (today) was selected...", _dateStr];
    else
        _msg = [NSString stringWithFormat:@"The marked date %@ was selected...", _dateStr];

} else {

    if (isToday)
        _msg = [NSString stringWithFormat:@"The date %@ (today) was selected...", _dateStr];
    else
        _msg = [NSString stringWithFormat:@"The date %@ was selected...", _dateStr];

}

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Date Selected" message:_msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}

// called when text popover menu is selected
//
//  popoverCalendar is the associated UIPopoverCalendarView object
//  popoverView is the associated PopoverView objec
//  index is the text menu item selected (0...n)
//  text is the text for the menu item selected
//
- (void)popoverCalendarView:(UIPopoverCalendarView *)popoverCalendar popoverView:(PopoverView *)popoverView didSelectItemAtIndex:(NSInteger)index text:(NSString *)text {

//NSLog(@"%s item: %d selected text: %@", __PRETTY_FUNCTION__, index, text);

NSString * _msg = [NSString stringWithFormat:@"The '%@' menu (menu #%d) was selected...", text, (index+1)];

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Menu Selected" message:_msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}

// called when view popover menu is selected
//
//  popoverCalendar is the associated UIPopoverCalendarView object
//  popoverView is the associated PopoverView objec
//  view is the view selected
//
- (void)popoverCalendarView:(UIPopoverCalendarView *)popoverCalendar popoverView:(PopoverView *)popoverView didSelectView:(UIView *)view contentView:(UIView *)contentView {

NSLog(@"%s selected view: %@ in contentView %@", __PRETTY_FUNCTION__, view, contentView);

NSString * text = @"";
NSString * _msg = nil;

if ([view isKindOfClass:[UILabel class]]) {
    UILabel * label = (UILabel *)view;
    text = label.text;
    _msg = [NSString stringWithFormat:@"The label with the text '%@' was selected...", text];

} else if ([view isKindOfClass:[UITextField class]]) {
    UITextField * field = (UITextField *)view;
    text = field.text;
    _msg = [NSString stringWithFormat:@"The text field with the text '%@' was selected...", text];

} else if ([view isKindOfClass:[UISlider class]]) {
    UISlider * slider = (UISlider *)view;
    text = [NSString stringWithFormat:@"slider value %f", slider.value];
    _msg = [NSString stringWithFormat:@"The slider with the value '%@' was selected...", text];
} else
    _msg = @"Unknown view selected!";

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"View Selected" message:_msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}

// called when the UIPopoverCalendarView (advanced, basic, text or view popover) is dismissed
- (void)popoverCalendarViewDidDismiss:(UIPopoverCalendarView *)popoverCalendar popoverView:(PopoverView *)popoverView {

//NSLog(@"%s popover dismissed.", __PRETTY_FUNCTION__);

}

Example Project Demo

The demo example in the Examples/Demo folder demonstrates how you might implement using UIPopoverCalendarView.

When run, the app displays various types of popover calendars and menus.

The example is for iOS.

Methods

// -----------------------------------

// static factory methods to create UIPopoverCalendarView…
//      (use syntax [UIPopoverCalendarView showAdvancedPopoverCalendarAtPoint .....];
//
// Notes:
//
// shows an advanced selectable calendar in a popup view...
// Note: current date is highlighted.  Marked dates are underlined in the associated marked date color.
//       if markedDates is nil, then the default underline marked color is red
//       current day is highlighted in blue
+ (UIPopoverCalendarView *)showAdvancedPopoverCalendarAtPoint:(CGPoint)point inView:(UIView *)view markedDates:(NSArray *)_markedDates markedDateColors:(NSArray*)_markedDateColors delegate:(id<PopoverCalendarViewDelegate>)_delegate;

// shows an advanced selectable calendar in a popup view...
// Note: current date is highlighted.  Marked dates are underlined in the associated marked date color.
//       if markedDates is nil, then the default underline marked color is red
+ (UIPopoverCalendarView *)showAdvancedPopoverCalendar:(UIView *)fromView inView:(UIView *)inView markedDates:(NSArray *)_markedDates markedDateColors:(NSArray*)_markedDateColors delegate:(id<PopoverCalendarViewDelegate>)_delegate;


// shows a basic non-selectable calendar at a specific point in a popup  view...
// Note: if date is nil, today is used
//       date specified is highlighted in blue.   If is today, then highlighted in blue.  If not today, then
//       date is highlighted in blue and current day in gray.
+ (UIPopoverCalendarView *)showPopoverCalendarAtPoint:(CGPoint)point inView:(UIView *)inView date:(NSDate *)_date delegate:(id<PopoverCalendarViewDelegate>)_delegate;

 // shows a basic non-selectable calendar with title at a specific point in a popup  view...
 //       date specified is highlighted in blue.   If is today, then highlighted in blue.  If not today, then
//       date is highlighted in blue and current day in gray.
+ (UIPopoverCalendarView *)showPopoverCalendarAtPoint:(CGPoint)point inView:(UIView *)inView withTitle:(NSString *)title date:(NSDate *)_date delegate:(id<PopoverCalendarViewDelegate>)_delegate;

// shows a basic non-selectable calendar in a popup  view...
// Note: if date is nil, today is used
//       date specified is highlighted in blue.   If is today, then highlighted in blue.  If not today, then
//       date is highlighted in blue and current day in gray.
+ (UIPopoverCalendarView *)showPopoverCalendar:(UIView *)fromView inView:(UIView *)inView date:(NSDate *)_date delegate:(id<PopoverCalendarViewDelegate>)_delegate;

// shows a basic non-selectable calendar with a title in a popup  view...
// Note: if date is nil, today is used
//       date specified is highlighted in blue.   If is today, then highlighted in blue.  If not today, then
//       date is highlighted in blue and current day in gray.
+ (UIPopoverCalendarView *)showPopoverCalendar:(UIView *)fromView inView:(UIView *)inView withTitle:(NSString *)title date:(NSDate *)_date delegate:(id<PopoverCalendarViewDelegate>)_delegate;

// show popover text view
+ (UIPopoverCalendarView *)showPopoverText:(UIView *)fromView inView:(UIView *)inView withTitle:(NSString *)title text:(NSArray *)stringArray delegate:(id<PopoverCalendarViewDelegate>)_delegate;

// show a popover view containing a content view (UIView)
+ (UIPopoverCalendarView *)showPopoverView:(UIView *)fromView inView:(UIView *)inView contentView:(UIView *)contentView delegate:(id<PopoverCalendarViewDelegate>)_delegate;


// Methods:
- (PopoverView *)getPopoverView;   // popover view used by UIPopoverCalendarView
- (NSArray *)getMarkedDates;       // array of NSDate objects - dates to mark on calendar
- (NSArray *)getMarkedDateColors;  // array of UIColor objects - colors used to mark (underline) marked dates on calendar
- (NSArray *)getStringArray;       // array of NSString objects being used fr text popover menu items
- (UIView *)getContentView;        // UIView object being used for popover view

- (BOOL)doesDismissAfterSelection;    // determines if popover dismisses after selected
- (void)setDismissAfterSelection:(BOOL)_dismiss;   // sets whether to dismiss popover after selection
- (float)getDismissAfterSelectionDuration;         // gets the dismiss popover animation delay
- (void)setDismissAfterSelectionDuration:(float)_duration;   // sets the dismiss popover animation delay

// date utilities

// get a date N days in the future or if - days (e.g. -10) days in the past...
+ (NSDate *)dateByAddingDays:(NSDate *)date days:(int)days;
- (NSString *)formatDate:(NSDate *)_date;            // nice format of date
- (NSDate *)getDateForDateStr:(NSString *)_dateStr;  // date for nice format date string
- (BOOL)isToday:(NSDate *)date;                      // determines if date is today
- (NSDate *)getToday;                                // get today's date
3 licenses, starting from From » $9.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.

or Get a quote

for customization or integration services


Or enter your name and Email
  • CM Carlos Marti License holderSingle App
    1 month support
    Purchased on Sep 8, 2014
    3 years ago
    You plan update your app to support the 64-bit. Thanks.
  • M Mahendra 4 years ago
    Does this work with iOS7 and also can I integrate this with other project of Xcode5? Please advise and I would love to buy developer license. Thanks
    • Thomas A. Markel Publisher 4 years ago
      yes for iOS7 and yes for other projects if buy developers license. Thanks for your interest.