Coder Social home page Coder Social logo

glcalendarview's Introduction

GLCalendarView

Demo

GLCalendarView

Installation

CocoaPods

With CocoaPods you can simply add GLCalendarView in your Podfile:

pod "GLCalendarView", "~> 1.0.0"

Source File

You can copy all the files under the Sources folder into your project.

Usage

  • Init the view by placing it in the storyboard or programmatically init it and add it to your view controller.
  • In viewDidLoad, set the firstDate and lastDate of the calendarView.
  • In viewWillAppear, set up the model data and call [self.calendarView reload]; to refresh the calendarView.

To display some ranges in the calendar view, construct some GLCalendarDateRange objects, set them as the model of the calendar view

NSDate *today = [NSDate date];
NSDate *beginDate = [GLDateUtils dateByAddingDays:-23 toDate:today];
NSDate *endDate = [GLDateUtils dateByAddingDays:-18 toDate:today];
GLCalendarDateRange *range = [GLCalendarDateRange rangeWithBeginDate:beginDate endDate:endDate];
range.backgroundColor = COLOR_BLUE;
range.editable = YES;
range.binding = yourModelObject // you can bind your model to the range

self.calendarView.ranges = [@[range1] mutableCopy];
[self.calendarView reload];

For the binding field, it helps in that you can bind the actual model to the range, thus you can easily retrieve the corresponding model from the range later. For example, if you are building a trip app, you probably has a Trip class, you can bind the Trip instance to the range, and if the range gets updated in the calendar view, you can easily get the Trip instance from it and do some further updates.

The calendar view will handle all the user interactions including adding, updating, or deleting a range, you just need to implement the delegate protocol to listen for those events:

@protocol GLCalendarViewDelegate <NSObject>
- (BOOL)calenderView:(GLCalendarView *)calendarView canAddRangeWithBeginDate:(NSDate *)beginDate;
- (GLCalendarDateRange *)calenderView:(GLCalendarView *)calendarView rangeToAddWithBeginDate:(NSDate *)beginDate;
- (void)calenderView:(GLCalendarView *)calendarView beginToEditRange:(GLCalendarDateRange *)range;
- (void)calenderView:(GLCalendarView *)calendarView finishEditRange:(GLCalendarDateRange *)range continueEditing:(BOOL)continueEditing;
- (BOOL)calenderView:(GLCalendarView *)calendarView canUpdateRange:(GLCalendarDateRange *)range toBeginDate:(NSDate *)beginDate endDate:(NSDate *)endDate;
- (void)calenderView:(GLCalendarView *)calendarView didUpdateRange:(GLCalendarDateRange *)range toBeginDate:(NSDate *)beginDate endDate:(NSDate *)endDate;
@end

Sample implementation:

- (BOOL)calenderView:(GLCalendarView *)calendarView canAddRangeWithBeginDate:(NSDate *)beginDate
{
    // you should check whether user can add a range with the given begin date
    return YES;
}

- (GLCalendarDateRange *)calenderView:(GLCalendarView *)calendarView rangeToAddWithBeginDate:(NSDate *)beginDate
{
    // construct a new range object and return it
    NSDate* endDate = [GLDateUtils dateByAddingDays:2 toDate:beginDate];
    GLCalendarDateRange *range = [GLCalendarDateRange rangeWithBeginDate:beginDate endDate:endDate];
    range.backgroundColor = [UIColor redColor];
    range.editable = YES;
    range.binding = yourModel // bind your model to the range instance
    return range;
}

- (void)calenderView:(GLCalendarView *)calendarView beginToEditRange:(GLCalendarDateRange *)range
{
    // save the range to a instance variable so that you can make some operation on it
    self.rangeUnderEdit = range;
}

- (void)calenderView:(GLCalendarView *)calendarView finishEditRange:(GLCalendarDateRange *)range continueEditing:(BOOL)continueEditing
{
    // retrieve the model from the range, do some updates to your model
    id yourModel = range.binding;
    self.rangeUnderEdit = nil;
}

- (BOOL)calenderView:(GLCalendarView *)calendarView canUpdateRange:(GLCalendarDateRange *)range toBeginDate:(NSDate *)beginDate endDate:(NSDate *)endDate
{
    // you should check whether the beginDate or the endDate is valid
    return YES;
}

- (void)calenderView:(GLCalendarView *)calendarView didUpdateRange:(GLCalendarDateRange *)range toBeginDate:(NSDate *)beginDate endDate:(NSDate *)endDate
{
    // update your model if necessary
    id yourModel = range.binding;
}

Appearance

GLCalendarView 's appearance is fully customizable, you can adjust its look through the appearance api(generally your should config it in the AppDelegate), check the header file to see all customizable fields:

[GLCalendarView appearance].rowHeight = 54;
[GLCalendarView appearance].padding = 6;
[GLCalendarView appearance].weekDayTitleAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:8], NSForegroundColorAttributeName:[UIColor grayColor]};
[GLCalendarView appearance].monthCoverAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:30]};

[GLCalendarDayCell appearance].dayLabelAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20], NSForegroundColorAttributeName:UIColorFromRGB(0x555555)};
[GLCalendarDayCell appearance].monthLabelAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:8]};
    
[GLCalendarDayCell appearance].editCoverBorderWidth = 2;
[GLCalendarDayCell appearance].editCoverBorderColor = UIColorFromRGB(0x366aac);
[GLCalendarDayCell appearance].editCoverPointSize = 14;

[GLCalendarDayCell appearance].todayBackgroundColor = UIColorFromRGB(0x366aac);
[GLCalendarDayCell appearance].todayLabelAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20]};

[GLCalendarDayCell appearance].rangeDisplayMode = RANGE_DISPLAY_MODE_CONTINUOUS;

You can clone the project and investigate the demo for more detailed usage~

glcalendarview's People

Contributors

3rdcycle avatar gelosi avatar ltebean avatar nevster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glcalendarview's Issues

Scrolling lag

The scrolling performance is not good in ipod touch/ iphone 4s

Can not get correct end date select from GLCalendarDateRange

Hello this is great library but I want to feedback can not get end date from select GLCalendarDateRange. Because it's have 2 different result.
Example: Click select 2016/7/30 but it's show 2016/7/29

  • (GLCalendarDateRange )calenderView:(GLCalendarView *)calendarView rangeToAddWithBeginDate:(NSDate *)beginDate
    {
    NSDate
    endDate = [GLDateUtils dateByAddingDays:0 toDate:beginDate];
    GLCalendarDateRange *range = [GLCalendarDateRange rangeWithBeginDate:beginDate endDate:endDate];
    range.backgroundColor = UIBackgroundColor;
    range.editable = YES;

    // range.endDate have different range
    NSLog(@"endDate: %@", range.endDate);
    NSLog(@" Add range: %@", range);
    return range;
    }

Not customizable First Day of Week

I'm trying to customize the first day of the week, to make it automatic.
I want the first day of the week, is the system default.

How i can do it?
Thanks.

Support for Swift 4 when?

Warning file:/Pods/GLCalendarView/GLCalendarView/Sources/GLCalendarView.xib: warning: Unsupported Configuration: This file is set to build for a version older than the deployment target. Functionality may be limited.

Not showing Month Cover Title

I use it on my Swift project. But the problem is when I scrolling, the month cover title not showing.

I alse put this line in AppDelegate.
GLCalendarView().monthCoverAttributes = [NSFontAttributeName:UIFont.systemFontOfSize(30),NSForegroundColorAttributeName:UIColor.redColor()]
but doesn't help. Anyone face this issue?

Loading nib from main bundle fails

Great pod! But I encountered a small problem...

I tried to integrate your calendar view in another app (through cocoa pods) and encountered this exception:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </private/var/mobile/Containers/Bundle/Application/B235DCB6-6243-4A1D-A82A-EFAD5E27E930/myapp.app> (loaded)' with name 'GLCalendarDayCell''

This is because the .xib is loaded from the main bundle (bundle:nil) at GLCalendarView.m:81

[self.collectionView registerNib:[UINib nibWithNibName:@"GLCalendarDayCell" bundle:nil] forCellWithReuseIdentifier:CELL_REUSE_IDENTIFIER];

Changing this to this line instead, makes it work.

[self.collectionView registerNib:[UINib nibWithNibName:@"GLCalendarDayCell" bundle:[NSBundle bundleForClass:self.class]] forCellWithReuseIdentifier:CELL_REUSE_IDENTIFIER];

Would you be so kind as to update the pod with this fix?

Thanks a lot!

show white screen

I am using the demo sample without storyboard ,it shows me the blank white screen.

How to add limit ?

Hi,

How to add limit to only one range selection be possible?

Thanks.

iPhone 5s drag issue

Hello!
In iPhone 5s not working period change when trying to drag.
Appreciate for any advices

Ranges turn into single selections

screenshot 2016-09-12 10 20 07

Not sure how to describe this, but sometimes the range shows correctly, and sometimes it shows up like the attached screenshot. I also noticed that if the range looked correct, then I scrolled the range off the screen, then scrolled back, some of these symptoms also showed up. Any thoughts?

Change calendar locale

Hello,

This is an awesome library!! I was wondering if you are able to allow the GLCalendarView to set a custom locale for its NSCalendar variable (which is readonly)?

Currently, it is using the currentLocale from the device. Which is not possible to override.

Thanks!

Set maximum days for range

Is there any way to set a maximum of days for a range, i.e. can dragging a range be limited to a specific maximum like 7 days only? Thanks.

Easier to select just one date range

I'd like the user to be able to select only one date range

I can do this by returning NO from:

- (BOOL)calenderView:(GLCalendarView *)calendarView canAddRangeWithBeginDate:(NSDate *)beginDate
  return NO;

}

However, it's then quite difficult for the user to select a new range to replace the old without deleting.

What I'd ideally like to achieve, is when the user selects a date outside of the current range, the existing range is deleted, and a new range is started where they click.

Is that possible?

Thanks

Weird white lines?

It's only happened on iPhone 6s Plus, can someone give any idea why? It keep showing random white lines

Here's how it look:
screen shot 2016-04-20 at 4 28 34 pm

Binding returning nil

Hi , i am having trouble while trying to bind a [String] to a range.
it returns nil , is that a bug ? or am i missing something ?

thanks

Can't select date after oct 24

Hi, I'm using your control in one of my apps, and i found that i'm not able to select a date after 24 oct 2015. there is any specific reason why or it's a bug.
when i try the app show an error. any help would be appreciate

screen shot 2015-09-22 at 11 19 43

App Crash - Could not load GLCalendarDayCell

Seeing a crash after installing through cocoapods v1.0.3 on iOS 10.2 simulator.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/....app> (loaded)' with name 'GLCalendarDayCell''

Not an issues but a request.

Hi, sorry to bother, but How can I make the backgroundCover to be in z position 1, always. When the user is dragging the range, I would like to see it over everything in the cell.
Thanks!
screen shot 2016-11-01 at 20 19 51

CalendarView Delegate

Hi,

My project is on Swift 2.2. I get a weird issue. I have to long press to trigger the delegate :/

what is wrong ?

Not showing monthCoverAttributes on scroll

I'am using GLCalendarView with Xcode 7 and Swift 2. Everything seems to be working fine, except the labels for the months that is supposed to show up when you scroll.

I have set the monthCoverAttributes in the AppDelegate.

GLCalendarView.appearance().monthCoverAttributes = [NSFontAttributeName: UIFont(name: "Lato-Semibold", size: 19)!, NSForegroundColorAttributeName: UIColor.blackColor()]

(Doesn't work even when i don't set the monthCoverAttributes)

Anyone facing same issue? Am I doing something wrong?

HockeyApp crash with GLCalendarView

I have a crash using GLCalendarView and it seems to be happening when [GLCalendarView scrollToDate:animated:] is called. I've never been able to reproduce, but it is consistently there in my HockeyApp reports. Any help debugging would be greatly appreciated.

Here is a log from HockeyApp.

Date/Time:       2016-03-27T09:29:22Z
Launch Time:     2016-03-27T09:27:09Z
OS Version:      iPhone OS 9.3 (13E233)
Report Version:  104

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x1000000000000
Crashed Thread:  0

Application Specific Information:
Selector name found in current argument registers: indexAtPosition:

Thread 0 Crashed:
0   libobjc.A.dylib                      0x00000001820780a8 objc_retain + 8
1   UIKit                                0x0000000187babd5c -[UICollectionViewData layoutAttributesForItemAtIndexPath:] + 248
2   UIKit                                0x0000000187dbd054 -[UICollectionView scrollToItemAtIndexPath:atScrollPosition:animated:] + 256
3   MyApp                          0x00000001000db180 -[GLCalendarView scrollToDate:animated:] (GLCalendarView.m:183)
4   MyApp                          0x00000001004592b8 MyApp.CalendarPickerViewController.((updateHighlightedDateRange in _CBEC18027870F1E53F5B993CDCCE3FFD) (MyApp.CalendarPickerViewController) -> () -> ()).(closure #1) (CalendarPickerViewController.swift:169)
5   libdispatch.dylib                    0x00000001824454bc _dispatch_call_block_and_release + 20
6   libdispatch.dylib                    0x000000018244547c _dispatch_client_callout + 12
7   libdispatch.dylib                    0x000000018244ab84 _dispatch_main_queue_callback_4CF + 1840
8   CoreFoundation                       0x00000001829b0dd8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
9   CoreFoundation                       0x00000001829aec40 __CFRunLoopRun + 1624
10  CoreFoundation                       0x00000001828d8d10 CFRunLoopRunSpecific + 380
11  GraphicsServices                     0x00000001841c0088 GSEventRunModal + 176
12  UIKit                                0x0000000187badf70 UIApplicationMain + 200
13  MyApp                          0x00000001000d3890 main (main.m:12)
14  ???                                  0x00000001824768b8 0x0 + 0

Thread 1:
0   libsystem_kernel.dylib               0x00000001825954d8 kevent_qos + 8
1   libdispatch.dylib                    0x0000000182447648 _dispatch_mgr_thread + 48

Thread 2:
0   libsystem_kernel.dylib               0x0000000182594b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018265d020 start_wqthread + 0

Thread 3:
0   libsystem_kernel.dylib               0x0000000182578fd8 mach_msg_trap + 8
1   CoreFoundation                       0x00000001829b0ce8 __CFRunLoopServiceMachPort + 192
2   CoreFoundation                       0x00000001829ae9ec __CFRunLoopRun + 1028
3   CoreFoundation                       0x00000001828d8d10 CFRunLoopRunSpecific + 380
4   CFNetwork                            0x0000000183059af4 +[NSURLConnection(Loader) _resourceLoadLoop:] + 408
5   Foundation                           0x00000001833cfe1c __NSThread__start__ + 996
6   libsystem_pthread.dylib              0x000000018265fb28 _pthread_body + 152
7   libsystem_pthread.dylib              0x000000018265fa8c _pthread_start + 152
8   libsystem_pthread.dylib              0x000000018265d028 thread_start + 0

Thread 4:
0   libsystem_kernel.dylib               0x0000000182578fd8 mach_msg_trap + 8
1   CoreFoundation                       0x00000001829b0ce8 __CFRunLoopServiceMachPort + 192
2   CoreFoundation                       0x00000001829ae9ec __CFRunLoopRun + 1028
3   CoreFoundation                       0x00000001828d8d10 CFRunLoopRunSpecific + 380
4   Foundation                           0x00000001832e8d8c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304
5   Foundation                           0x000000018333dff8 -[NSRunLoop(NSRunLoop) run] + 84
6   MyApp                          0x00000001006198f0 +[GAI threadMain:] + 68
7   Foundation                           0x00000001833cfe1c __NSThread__start__ + 996
8   libsystem_pthread.dylib              0x000000018265fb28 _pthread_body + 152
9   libsystem_pthread.dylib              0x000000018265fa8c _pthread_start + 152
10  libsystem_pthread.dylib              0x000000018265d028 thread_start + 0

Thread 5:
0   libsystem_kernel.dylib               0x0000000182594344 __select + 8
1   libsystem_pthread.dylib              0x000000018265fb28 _pthread_body + 152
2   libsystem_pthread.dylib              0x000000018265fa8c _pthread_start + 152
3   libsystem_pthread.dylib              0x000000018265d028 thread_start + 0

Thread 6:
0   libsystem_kernel.dylib               0x0000000182578fd8 mach_msg_trap + 8
1   CoreFoundation                       0x00000001829b0ce8 __CFRunLoopServiceMachPort + 192
2   CoreFoundation                       0x00000001829ae9ec __CFRunLoopRun + 1028
3   CoreFoundation                       0x00000001828d8d10 CFRunLoopRunSpecific + 380
4   Foundation                           0x00000001832e8d8c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304
5   Foundation                           0x000000018333dff8 -[NSRunLoop(NSRunLoop) run] + 84
6   MyApp                          0x0000000100098684 +[AFURLConnectionOperation networkRequestThreadEntryPoint:] (AFURLConnectionOperation.m:163)
7   Foundation                           0x00000001833cfe1c __NSThread__start__ + 996
8   libsystem_pthread.dylib              0x000000018265fb28 _pthread_body + 152
9   libsystem_pthread.dylib              0x000000018265fa8c _pthread_start + 152
10  libsystem_pthread.dylib              0x000000018265d028 thread_start + 0

Thread 7:
0   libsystem_kernel.dylib               0x0000000182578fd8 mach_msg_trap + 8
1   CoreFoundation                       0x00000001829b0ce8 __CFRunLoopServiceMachPort + 192
2   CoreFoundation                       0x00000001829ae9ec __CFRunLoopRun + 1028
3   CoreFoundation                       0x00000001828d8d10 CFRunLoopRunSpecific + 380
4   GeoServices                          0x000000018956a160 _runNetworkThread + 424
5   libsystem_pthread.dylib              0x000000018265fb28 _pthread_body + 152
6   libsystem_pthread.dylib              0x000000018265fa8c _pthread_start + 152
7   libsystem_pthread.dylib              0x000000018265d028 thread_start + 0

Thread 8:
0   libsystem_kernel.dylib               0x0000000182578fd8 mach_msg_trap + 8
1   CoreFoundation                       0x00000001829b0ce8 __CFRunLoopServiceMachPort + 192
2   CoreFoundation                       0x00000001829ae9ec __CFRunLoopRun + 1028
3   CoreFoundation                       0x00000001828d8d10 CFRunLoopRunSpecific + 380
4   WebCore                              0x00000001868c2558 RunWebThread(void*) + 452
5   libsystem_pthread.dylib              0x000000018265fb28 _pthread_body + 152
6   libsystem_pthread.dylib              0x000000018265fa8c _pthread_start + 152
7   libsystem_pthread.dylib              0x000000018265d028 thread_start + 0

Thread 9:
0   libsystem_kernel.dylib               0x0000000182593f24 __psynch_cvwait + 8
1   libc++.1.dylib                       0x0000000181feb42c std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 52
2   JavaScriptCore                       0x00000001863a92cc JSC::GCThread::waitForNextPhase() + 140
3   JavaScriptCore                       0x00000001863a9364 JSC::GCThread::gcThreadMain() + 80
4   JavaScriptCore                       0x000000018607ed44 WTF::threadEntryPoint(void*) + 208
5   JavaScriptCore                       0x000000018607ec54 WTF::wtfThreadEntryPoint(void*) + 20
6   libsystem_pthread.dylib              0x000000018265fb28 _pthread_body + 152
7   libsystem_pthread.dylib              0x000000018265fa8c _pthread_start + 152
8   libsystem_pthread.dylib              0x000000018265d028 thread_start + 0

Thread 10:
0   libsystem_kernel.dylib               0x0000000182594b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018265d020 start_wqthread + 0

Thread 11:
0   libsystem_kernel.dylib               0x0000000182594b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018265d020 start_wqthread + 0

Thread 12:
0   libsystem_kernel.dylib               0x0000000182594b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018265d020 start_wqthread + 0

Thread 13:
0   libsystem_kernel.dylib               0x0000000182594b48 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018265d020 start_wqthread + 0

Bundle Error when install with Cocoapods

Hi, if I install the lib via cocoapods, i always have the crash that it cant find the nib for the cell, because it's pointing bundle nil, which is not suitable for cocoapods, hope u can update so that it will check for bundle and load correct nib files

Crash on iOS 10.3

The library causing crash on iOS 10.3. Anyone got clue about that?

Use in landscape

Can this library be used in portrait and in landscape? It seems to break (look bad) whenever I go into landscape.

Broken constraints. Help.

Hello, i have trouble with your view.
When i set 10 ranges and set begin date to current date, constraints break.

Please, help me as soon as possible. I have to complete this screen yesterday.
2016-04-27 10 44 25

Console:

2016-04-27 10 50 17

Code to create:

- (void)viewDidLoad {
  [super viewDidLoad];

  self.calendarView.delegate = self;
  self.calendarView.showMagnifier = YES;
  if (self.editItinerary) {
    NSDateComponents *components =
    [[NSCalendar currentCalendar] components:NSCalendarUnitYear |
                                             NSCalendarUnitMonth
                                    fromDate:self.editItinerary.startDate];
    components.day = 1;
    self.calendarView.firstDate = [[NSCalendar currentCalendar] dateFromComponents:components];
  } else {
    NSDateComponents *components =
        [[NSCalendar currentCalendar] components:NSCalendarUnitYear |
                                                 NSCalendarUnitMonth
                                        fromDate:[NSDate date]];
    components.day = 1;
    self.calendarView.firstDate = [[NSCalendar currentCalendar] dateFromComponents:components];
  }
  self.calendarView.lastDate = [NSDate dateWithTimeIntervalSinceNow:60*60*24*365]; // + 1 years
  self.calendarView.rowHeight =
      (CGRectGetWidth(self.view.bounds) - self.calendarView.padding * 2 + 30) / 7;
  [GLCalendarDayCell appearance].rangeDisplayMode = RANGE_DISPLAY_MODE_CONTINUOUS;

  NSString *title;
  if (self.location) { // It's creating
    title = self.location.shortName;
    [self.placeImageView sd_setImageWithURL:self.location.bigImageURL];
    self.deleteButton.hidden = YES;
  } else { // It's editing already existed itinerary
    title = self.editItinerary.location.shortName;
    [self.placeImageView sd_setImageWithURL:self.editItinerary.location.bigImageURL
     placeholderImage:[UIImage imageNamed:@"ph_town_big"]];
  }
  self.title = title;

  for (LOMItinerary *userItinerary in self.userItineraries) {
    GLCalendarDateRange *range =
        [GLCalendarDateRange rangeWithBeginDate:userItinerary.startDate
                                        endDate:userItinerary.endDate];
    range.editable = NO;
    range.backgroundColor = [UIColor colorWithRed:233.f/255.f
                                            green:233.f/255.f
                                             blue:233.f/255.f
                                            alpha:1.f];
    range.textColor = [UIColor whiteColor];
    [self.calendarView addRange:range];
  }

}

- (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];

  [self.calendarView reload];
  __weak LOMAddItineraryViewController *weakSelf = self;
  dispatch_async(dispatch_get_main_queue(), ^{
      // It have to be in main async block. Else it doesn't work.
      NSDate *dateToScroll;
      if (weakSelf.location) {
        dateToScroll = [NSDate date];
      } else {
        dateToScroll = weakSelf.editItinerary.startDate;
        GLCalendarDateRange *range =
        [GLCalendarDateRange rangeWithBeginDate:weakSelf.editItinerary.startDate
                                        endDate:weakSelf.editItinerary.endDate];
        range.editable = NO;
        range.backgroundColor = [UIColor colorWithRed:250.f/255.f
                                                green:132.f/255.f
                                                 blue:132.f/255.f
                                                alpha:1.f];
        range.textColor = [UIColor whiteColor];
        [weakSelf.calendarView addRange:range];
        weakSelf.currentRange = range;
      }
      [weakSelf.calendarView scrollToDate:dateToScroll animated:NO];
  });
}

Does not work for iPad

Its working in iPhone, but it doesn't work in iPad. Is there any thing to set to make it work for iPad? Thanks Sachin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.