Git Product home page Git Product logo

kal's Introduction

Kal - a calendar component for the iPhone

This project aims to provide an open-source implementation of the month view in Apple's mobile calendar app (MobileCal). When the user taps a day on the calendar, any associated data for that day will be displayed in a table view directly below the calendar. As a client of the Kal component, you have 2 responsibilities:

  1. Tell Kal which days need to be marked with a dot because they have associated data.
  2. Provide UITableViewCells which display the details (if any) for the currently selected day.

In order to use Kal in your application, you will need to provide an implementation of the KalDataSource protocol to satisfy these responsibilities. Please see KalDataSource.h and the included demo app for more details.

Release Notes

June 21, 2012

Today I added VoiceOver/Accessibility support. Special thanks to Matt Gemmell's excellent article on adding accessibility support to your iPhone app. I wish I would have done this a long time ago.

If your app is localized, then you will also want to localize the 4 new accessibility strings that I added in this release: "Previous month", "Next month", "Marked" and "Today".

July 9, 2010

This is the iOS 4.0 / iPhone4 release. New features include:

  1. A refactored project file. Kal is now built as a static library in a separate Xcode project. Regardless of whether you are a new or existing user of Kal, please read the section entitled "Integrating Kal into Your Project" below.

  2. The project now specifies iOS 4.0 as the Base SDK. So if you want to upgrade to this release of Kal, you must upgrade your SDK.

  3. Added hi-res graphics for Retina Display support. Extra special thanks to Paul Calnan for sending me the hi-res graphics.

  4. Added a new example app, "NativeCal," which demonstrates how to integrate Kal with the EventKit framework that Apple made available in iOS 4.

NOTE I'm not crazy about the KalDataSource asynchronous/synchronous API. I will probably be changing it in the future and updating the example apps to use GCD and blocks.

March 11, 2010

A lot of people have emailed me asking for support for selecting and displaying an arbitrary date on the calendar. So today I pushed some commits that make this easy to do. You can specify which date should be initially selected and shown when the calendar is first created by using -[KalViewController initWithSelectedDate:]. If you would like to programmatically switch the calendar to display the month for an arbitrary date and select that date, use -[KalViewController showAndSelectDate:].

January 1, 2010

I have made significant changes to the KalDataSource API so that the client can respond to the data request asynchronously. The Kal demo app, "Holidays," now includes 2 example datasources:

  1. HolidayJSONDataSource - retrieves data asynchronously from http://keith.lazuka.org/holidays.json
  2. HolidaySqliteDataSource - queries an Sqlite database inside the application bundle and responds synchronously (because the query is fast enough that it doesn't affect UI responsiveness too badly).

December 19, 2009

Initial public release on GitHub.

Example Usage

Note: All of the following example code assumes that it is being called from within another UIViewController which is in a UINavigationController hierarchy.

How to display a very basic calendar (without any events):

KalViewController *calendar = [[[KalViewController alloc] init] autorelease];
[self.navigationController pushViewController:calendar animated:YES];

In most cases you will have some custom data that you want to attach to the dates on the calendar. The first thing you must do is provide an implementation of the KalDataSource protocol. Then all you need to do to display your annotated calendar is instantiate the KalViewController and tell it to use your KalDataSource implementation (in this case, "MyKalDataSource"):

id<KalDataSource> source = [[MyKalDataSource alloc] init];
KalViewController *calendar = [[[KalViewController alloc] initWithDataSource:source] autorelease];
[self.navigationController pushViewController:calendar animated:YES];

NOTE: KalViewController does not retain its datasource. You probably will want to store a reference to the dataSource in an instance variable so that you can release it after the calendar has been destroyed.

Integrating Kal into Your Project

Kal is compiled as a static library, and the recommended way to add it to your project is to use Xcode's "dependent project" facilities by following these step-by-step instructions:

  1. Clone the Kal git repository: git clone git://github.com/klazuka/Kal.git. Make sure you store the repository in a permanent place because Xcode will need to reference the files every time you compile your project.
  2. Locate the "Kal.xcodeproj" file under "Kal/src/". Drag Kal.xcodeproj and drop it onto the root of your Xcode project's "Groups and Files" sidebar. A dialog will appear -- make sure "Copy items" is unchecked and "Reference Type" is "Relative to Project" before clicking "Add".
  3. Now you need to link the Kal static library to your project. Select the Kal.xcodeproj file that you just added to the sidebar. Under the "Details" table, you will see libKal.a. Check the checkbox on the far right for this file. This will tell Xcode to link against Kal when building your app.
  4. Now you need to add Kal as a dependency of your project so that Xcode will compile it whenever you compile your project. Expand the "Targets" section of the sidebar and double-click your application's target. Under the "General" tab you will see a "Direct Dependencies" section. Click the "+" button, select "Kal" and click "Add Target".
  5. Now you need to add the bundle of image resources internally used by Kal's UI. Locate "Kal.bundle" under "Kal/src" and drag and drop it into your project. A dialog will appear -- make sure "Create Folder References" is selected, "Copy items" is unchecked, and "Reference Type" is "Relative to Project" before clicking "Add".
  6. Finally, we need to tell your project where to find the Kal headers. Open your "Project Settings" and go to the "Build" tab. Look for "Header Search Paths" and double-click it. Add the relative path from your project's directory to the "Kal/src" directory.
  7. While you are in Project Settings, go to "Other Linker Flags" under the "Linker" section, and add "-all_load" to the list of flags.
  8. You're ready to go. Just #import "Kal.h" anywhere you want to use KalViewController in your project.

Additional Notes

The Xcode project includes two demo apps:

  1. "Holiday" demonstrates how to use Kal to display several 2009 and 2010 world holidays using both JSON and Sqlite datasources.
  2. "NativeCal" demonstrates how to use Kal with the EventKit framework.

Kal is fully localized. The month name and days of the week will automatically use the appropriate language and style for the iPhone's current regional settings.

kal's People

Contributors

klazuka 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  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

kal's Issues

Cannot use Kal with Xcode4

Hello,

I've been trying for quite a while now to use Kal with an Xcode4 project. I've tried both integrating into a normal project and the new workspace feature. I've now used both Xcode 4.02 and 4.1

These are the existing instructions for Xcode3. I've put the issues I'm face prefaced with a ******** :

2] Locate the "Kal.xcodeproj" file under "Kal/src/". Drag Kal.xcodeproj and drop it onto the root of your Xcode project's "Groups and Files" sidebar. A dialog will appear -- make sure "Copy items" is unchecked and "Reference Type" is "Relative to Project" before clicking "Add".

******** Two issue. When I drag over or right-click 'add file' Kal.xcodeproj just shows up as a 'flat' file. I can't expand like you would a normal project. It just looks like a little project icon and thats it.

3] Now you need to link the Kal static library to your project. Select the Kal.xcodeproj file that you just added to the sidebar. Under the "Details" table, you will see libKal.a. Check the checkbox on the far right for this file. This will tell Xcode to link against Kal when building your app.

******** In Xcode 4 I select the project on the left side, then Target, then Build Phases. Select Target Dependencies and click the Plus. Nothing appears here. I can select the static library.

4] Now you need to add Kal as a dependency of your project so that Xcode will compile it whenever you compile your project. Expand the "Targets" section of the sidebar and double-click your application's target. Under the "General" tab you will see a "Direct Dependencies" section. Click the "+" button, select "Kal" and click "Add Target".

******** Where do I do this in Xcode 4 ?

5] Now you need to add the bundle of image resources internally used by Kal's UI. Locate "Kal.bundle" under "Kal/src" and drag and drop it into your project. A dialog will appear -- make sure "Create Folder References" is selected, "Copy items" is unchecked, and "Reference Type" is "Relative to Project" before clicking "Add".

******** This works fine.

6] Finally, we need to tell your project where to find the Kal headers. Open your "Project Settings" and go to the "Build" tab. Look for "Header Search Paths" and double-click it. Add the relative path from your project's directory to the "Kal/src" directory.
While you are in Project Settings, go to "Other Linker Flags" under the "Linker" section, and add "-all_load" to the list of flags.
You're ready to go. Just #import "Kal.h" anywhere you want to use KalViewController in your project.

******** This works fine.

So likely due to not being able to include the static library, I get these errors :
Apple_Mach0_Linker_Error : KalViewController
Apple_Mach0_Linker_Error : KalDataSourceChangedNotifications.

The examples do work. As far as I am aware my project Kal set up is the same.

Any pointers? Thanks.

Several users reporting crash related to Kal

Greetings, I first want to say that I love the Kal framework - very cool.

Recently several users have reported that upon tapping the UIButton which pushes a KalViewController onto the navigation stack my application crashes. It seems that it is only a small number of users (only about 7 have reported this). Most say that everything is working just fine. One of the users provided me with his crash logs which pointed me towards the following lines of code, with "receivedTouches" coming up as the final call to my framework before the crash. "loadItemsFrom" is just behind it so I thought I'd inspect there as well, but cannot seem to find anything in either:

-[KalGridView receivedTouches:withEvent:](in myApp) (KalGridView.m:118)
//AND
-[KALDataSource loadItemsFrom:to:delegate:](in myApp) (KALDataSource.m:147)

Here are the two methods these lines are pointing to. I cannot see anything that would cause a crash though. Any help is greatly appreciated:

  • (void)receivedTouches:(NSSet *)touches withEvent:event
    {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self];
    UIView *hitView = [self hitTest:location withEvent:event];

    if (!hitView)
    return;

    //ATOS SPECIFICALLY INDICATES THE "IF" LINE BELOW
    if ([hitView isKindOfClass:[KalTileView class]]) {
    KalTileView tile = (KalTileView)hitView;
    if (tile.belongsToAdjacentMonth) {
    self.highlightedTile = tile;
    } else {
    self.highlightedTile = nil;
    self.selectedTile = tile;
    }
    }
    }

//AND

  • (void)loadItemsFrom:(NSDate *)fromDate to:(NSDate *)toDate delegate:(id)delegate
    {

    int i;

    for (i = 0; i < [MainDataArray count]; i++) {
    NSString *name;
    NSString *comment;
    NSString *number;
    NSString *score;

    NSMutableDictionary *d = [[NSMutableDictionary alloc] initWithDictionary:[MainDataArray objectAtIndex:i]];
    name = [d objectForKey:@"theName"];
    comment = [d objectForKey:@"theDesc"];
    score = [NSString stringWithFormat:@"%@ %@", [d objectForKey:@"theScoreType"], [d objectForKey:@"theScore"]];
    int n = i;
    
    number = [NSString stringWithFormat:@"%i", n];
    //ATOS SPECIFICALLY INDICATES NSDATEFORMATTER LINE BELOW
    NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
    [fmt setDateFormat:@"MMM dd, yyyy"];
    NSDate *date = [fmt dateFromString:[d objectForKey:@"theDate"]];
    
    [fmt release];
    
    [items addObject:[anItem itemNamed:name country:score date:date rowNumber:number]];
    
     [d release];
    

    }

    [delegate loadedDataSource:self];
    }

Please help!

Why doesn't show content in the first tileview every month?

I have to show something in the first tile view.
For example, I let 2011/3/27 have a event. In March,I can see a dot in 27 tile view. When I turn to April, I see the front month 3/27 is gray text. But I can't see dot in April.
So, I research it. It's the first tile of every month not show event.
How do fix it ?

Feature Request: iPad Support / Layout

I've previously done this with TapkuLibrary's Calendar, but I've since run into issues with drawing on 4.2.x. So now I'm trying to scope out how to implement an iPad-specific layout for Kal. To give you an idea of what I have in mind, here's an image:

IB layout, with shadows

The grid view on the top left, the table view on the top right, and a detail view (in my case a uiwebcontroller) at the bottom. Any thoughts? Have you already looked into iPad support for Kal?

KalViewController cannot be instantiated through xib

Your examples only show the viewcontroller being instantiated and pushed. If I try to place a KalViewController as a view inside of a navigation controller, I get the following exception when I try to access the view:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to find corresponding tile for date 0/0/0'
*** Call stack at first throw:
(
0 CoreFoundation 0x02505919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x026535de objc_exception_throw + 47
2 CoreFoundation 0x024be078 +[NSException raise:format:arguments:] + 136
3 Foundation 0x000d28cf -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
...

It looks like the we need a force the init call with today's date somehow. Can you document this?

Kalviewcontroller in xib

Hello

I try to put the Kalviewcontroller replacing the viewcontroller class in xib. When i run the app i show this error: Failed to find corresponding tile for date 0/0/0

The problem is that i need to show inside UItabBarcontroller not in a separate view.

I Try to put in the .m file of the view the code:

  • (id) initWithCoder:(NSCoder *)aDecoder {
    return [self initWithSelectedDate:[NSDate date]];

}

But nothing happends.

Can you help me?

Thanks

gradient on header view

Hi Keith,

I was wondering if you were planning on using stretchableImageWithLeftCapWidth on the headerView as well, right now I don't see a gradient. I tried adding that method and the gradient showed up. Something small but I thought I would bring it up. This is a great piece of code.

John

Is Kal still under development?

Shall we use klazuka/Kal or other Kal forks? I am confused by so many forks that advanced klazuka but difficult to test their stability one by one. Many forks have their own updates on ARC or Xcode 4.2.

Kal width in popover view

the navigationbar and toolbar are too wide when using Kal in a popover view. Everything else is the size of the popover. Is there a way to set the width correctly?

Change start and end date of month?

Hello.

I was just wondering if there's any way to change the first and last day of the month, as i'd like the month to span from the 25th to the 24th, instead of from the 1st to the 28th/30th/31st.

Thanks.

Do you intend to make an iPad version of KalViewController?

I've been looking for an iPad calendar control similar to the one in iPad's calendar application but I couldn't find any and I'm not comfortable enough with control development to do it myself. At least not quickly. And since you're drawing the component yourself, Kal would be an excellent starting point.

Is that possible to change the grid view date button color?

Sorry this is not an issue, I don't know where should I put my question.
I just want to know how can I change the grid view date button color? For example, April 1 to April 15 is marked as red color, April 20 to April 23 marked as green color.

Is that possible?

Crash on return to Calendar grid view after backgrounding

Hi - great code btw!

This can be reproduced with your holiday app on a device. (I've been testing on my 4.2.1 iPhone 4) Potentially fiddly one to fix - interested to hear your thoughts...

Steps to reproduce:

  1. Start your Holiday app
  2. Slide to the next month (i.e. not the current month)
  3. Select an event and view the holiday details
  4. When on the details screen, quit to the springboard by single clicking the home button (not double clicking to background). We need to force the device to want to reload the grid when we return - so you may need to do some memory intensive stuff - but not generally the case for me.
  5. Relaunch the Holiday app. This returns you to the details screen
  6. Now press back to return to the grid. Crash log below

From the looks of the code this is happening because the 'logic' object is still on the next month (correct), but when loadView is triggered by the OS trying to re-instantiate the view it defaults to setting the current date on the grid - which was in the previous month so assertion fails as cell is nil.

Thought about maintaining last user-selected date but started to get fiddly.

2011-02-02 08:20:24.961 Holiday[3471:307] Received memory warning. Level=2
2011-02-02 08:20:28.382 Holiday[3471:307] *** Assertion failure in -[KalMonthView tileForDate:], /Users/j.christian/dev/Kal/src/KalMonthView.m:84
2011-02-02 08:20:28.510 Holiday[3471:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to find corresponding tile for date 2/2/2011'
*** Call stack at first throw:
(
0 CoreFoundation 0x33ac0987 exceptionPreprocess + 114
1 libobjc.A.dylib 0x3347b49d objc_exception_throw + 24
2 CoreFoundation 0x33ac07c9 +[NSException raise:format:arguments:] + 68
3 Foundation 0x3366b29f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4 Holiday 0x00007bd1 -[KalMonthView tileForDate:] + 256
5 Holiday 0x00006539 -[KalGridView selectDate:] + 24
6 Holiday 0x00008b1f -[KalView selectDate:] + 22
7 Holiday 0x0000a0f3 -[KalViewController loadView] + 262
8 UIKit 0x320a0227 -[UIViewController view] + 30
9 UIKit 0x320acd0b -[UIViewController contentScrollView] + 22
10 UIKit 0x320acb7b -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 30
11 UIKit 0x320aca79 -[UINavigationController _layoutViewController:] + 24
12 UIKit 0x320ac551 -[UINavigationController _startTransition:fromViewController:toViewController:] + 380
13 UIKit 0x320ac35f -[UINavigationController _startDeferredTransitionIfNeeded] + 182
14 UIKit 0x32101f4d -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:] + 340
15 UIKit 0x32101df3 -[UINavigationController popViewControllerAnimated:] + 26
16 UIKit 0x32101c9d -[UINavigationController navigationBar:shouldPopItem:] + 96
17 UIKit 0x32101adb -[UINavigationBar _popNavigationItemWithTransition:] + 74
18 UIKit 0x32101a73 -[UINavigationBar popNavigationItemAnimated:] + 82
19 UIKit 0x32101935 -[UINavigationBar _handleMouseUpAtPoint:] + 396
20 UIKit 0x32101795 -[UINavigationBar touchesEnded:withEvent:] + 60
21 UIKit 0x3207b355 -[UIWindow _sendTouchesForEvent:] + 368
22 UIKit 0x3207accf -[UIWindow sendEvent:] + 262
23 UIKit 0x32065fc7 -[UIApplication sendEvent:] + 298
24 UIKit 0x32065907 _UIApplicationHandleEvent + 5090
25 GraphicsServices 0x33b0ef03 PurpleEventCallback + 666
26 CoreFoundation 0x33a556ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION
+ 26
27 CoreFoundation 0x33a556c3 __CFRunLoopDoSource1 + 166
28 CoreFoundation 0x33a47f7d __CFRunLoopRun + 520
29 CoreFoundation 0x33a47c87 CFRunLoopRunSpecific + 230
30 CoreFoundation 0x33a47b8f CFRunLoopRunInMode + 58
31 GraphicsServices 0x33b0e4ab GSEventRunModal + 114
32 GraphicsServices 0x33b0e557 GSEventRun + 62
33 UIKit 0x32099329 -[UIApplication _run] + 412
34 UIKit 0x32096e93 UIApplicationMain + 670
35 Holiday 0x000023ed main + 48
36 Holiday 0x000023b8 start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.

Calendar title is hard coded to "Calendar"

In working with the example Holiday.xcodeproj, I saw that the app delegate sets the title of the calendar to "Holiday" but it shows "Calendar" instead. Inside KalViewController.m in the loadView method, the title gets set to @"Calendar". I just commented that line out and now it works fine.

I've never worked with any sort of open source software, so I wouldn't know where to start to "contribute" this to the code, but I'm sure someone here can. =)

How to retun a date..

Hi Klazuka,
I am new to iOs dev. I started to use Kal calendar in my first app and i would like to return the date selected by the user on the month view to my main app. What is the easiest way to do this? Thanks in advance.

Cannot Create .ipa file

Hello, I recently integrated Kal into my project and before that I was able to create an IPA file for Ad Hoc distribution using a free service called TestFlight. Anyway, now that Kal is integrated into my project I can still archive my project but when I click "share" in the organizer, now I only have the "Built Products" and "Archive" options. The option to create a package is greyed out. I've been trying to mess around with some of the build settings, but I can't figure it out. Any help would be much appreciated.

Thanks,
Chris

Landscape mode problem

Great job. Thanks for the contribution.

When opening view modally works great. When opening view using push in landscape mode view looks wrong. Subsequent calls to kalviewcontroller even in portrait mode look wrong (same object).

Can you fix this so it is compatible with landscape mode? Thank you

Using Kal withing another UIViewController

Hi,

I am trying to use Kal within another UIViewController:

In my UIViewControler's 'viewDidLoad':

[self.view addSubview:kal.view];

However user events are not getting passed to other controls in the view.

The Apple "View Controller Programming Guide for iOS" warns that a view from a view controller should not be nested in the view of another view controller.

I also tried instantiating KalView directly and adding that as a sub view to my view controller, but I have the same problem with messages not getting to other controls in the view.

Is there a way to use Kal within another view controller? Can I use KalView without KalViewController?

Thanks,
Tim

Date formatter's format

Now date formatter's format looks like that:
[monthAndYearFormatter setDateFormat:@"MMMM yyyy"];

And it causes troubles with when Russian is set as a regional format. Changing this to
[monthAndYearFormatter setDateFormat:@"LLLL yyyy"];
solves the problem.

According to this page (link from Apple's Data Formatting Guide)
http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns
"L" should be used as a month specifier for stand-alone month. And when it is used in Kal, it is stand-alone: "January 2010", not "January 1, 2010". We don't see it in English or in German, because both forms—stand-alone and not stand-alone—are the same. In Russian they are not, and the current calendar title incorrectly reads something like "of January 2010" instead of just "January 2010".

'Adjacent' days, when selected, the gray fill is not filled correctly

This is due to a bug in (void)setType of KalTileView:

there's:
if (tileType == KalTileTypeToday) {
...
} else {
...
}

well, the else should be:
} else if (flags.type == KalTileTypeToday) {
...
}

Because you only need to revert the frame offset if it was previously set, not always. What happens right now, is that the flags for these tiles are set to Adjacent, and it gets an offset, which was only supposed to be a counter-offset for the Today frame offset.

Hope I helped.

Kal on iPad and current selected date

Hi,

I am trying to use Kal in an iPad app, and, i need to get the selected date to update some label in UI.
How can i get the date selected by user ?

However thanks for this lib.

French localization

Hello, thanks for the great work. I am currently localizing my app to French. I noticed that the French localization is not working correctly (Kal stays in English). I have tried terminating the app, even completly shutting down the iPhone and still Kal remains in English. Thanks again for your great work.

Few tweaks to make this work on an iPad

Minor diff below to make things easier on the iPad; basically we need to not take the size of the screen as our view port - but live in whatever view we are put.

Dw.

diff --git a/src/KalViewController.h b/src/KalViewController.h
index fa4d28e..60977a1 100644
--- a/src/KalViewController.h
+++ b/src/KalViewController.h
@@ -26,12 +26,15 @@
UITableView *tableView;
id delegate;
id dataSource;

  • CGRect frame;
    NSDate *initialSelectedDate;
    }

@Property (nonatomic, assign) id delegate;
@Property (nonatomic, assign) id dataSource;

+- (id) initWithFrame:(CGRect)frame; //
+- (id) initWithSelectedDate:(NSDate *)selectedDate withFrame:(CGRect)frame;

  • (id)initWithSelectedDate:(NSDate *)selectedDate; // designated initializer. When the calendar is first displayed to the user, the month that contains 'selectedDate' will be shown and the corresponding tile for 'selectedDate' will be automatically selected.

  • (void)reloadData; // If you change the KalDataSource after the KalViewController has already been displayed to the user, you must call this method in order for the view to reflect the new data.

  • (void)showAndSelectDate:(NSDate *)date; // Updates the state of the calendar to display the specified date's month and selects the tile for that date.
    diff --git a/src/KalViewController.m b/src/KalViewController.m
    index 93521ea..60194b8 100644
    --- a/src/KalViewController.m
    +++ b/src/KalViewController.m
    @@ -38,9 +38,24 @@ NSString *const KalDataSourceChangedNotification = @"KalDataSourceChangedNotific

    @synthesize dataSource, delegate;

+- (id) init {

  • return [self initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    +}

+- (id) initWithFrame:(CGRect)_frame
+{

  • return [self initWithSelectedDate:[NSDate date] withFrame:_frame];
    +}
  • (id)initWithSelectedDate:(NSDate *)selectedDate
    {
  • return [self initWithSelectedDate:(NSDate *)selectedDate withFrame:[[UIScreen mainScreen] applicationFrame]];
    +}

+- (id)initWithSelectedDate:(NSDate *)selectedDate withFrame:(CGRect)_frame
+{
if ((self = [super init])) {

  • frame = _frame;
    logic = [[KalLogic alloc] initForDate:selectedDate];
    initialSelectedDate = [selectedDate retain];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(significantTimeChangeOccurred) name:UIApplicationSignificantTimeChangeNotification object:nil];
    @@ -49,10 +64,7 @@ NSString *const KalDataSourceChangedNotification = @"KalDataSourceChangedNotific
    return self;
    }

-- (id)init
-{

  • return [self initWithSelectedDate:[NSDate date]];
    -}
  • (KalView_)calendarView { return (KalView_)self.view; }

@@ -167,11 +179,18 @@ NSString *const KalDataSourceChangedNotification = @"KalDataSourceChangedNotific
// -----------------------------------------------------------------------------------
#pragma mark UIViewController

  • (void)loadView
    {
    self.title = @"Calendar";
  • KalView *kalView = [[KalView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] delegate:self logic:logic];
  • // Keep things nicely square for now.
  • //
  • if(frame.size.width > 322.0) // 7 * kTileSize.width
  • frame.size.width = 322.0;
    
  • KalView *kalView = [[KalView alloc] initWithFrame:frame delegate:self logic:logic];
    self.view = kalView;
    tableView = kalView.tableView;
    tableView.dataSource = dataSource;

I can't see anything in first tileview.

I just ran the Holidays example app too. My problem is when I input a event into March 27th 2011. I can see a dot when viewing March 2011.
But when I press next month button to April 2011, I can't see a dot in "grayed-out" March 27th 2011.
It's not April 1st 2011.

PS: This situation was happened in May 1st 2011.

Thanks for your reply.

How to make a date unselected?

Hi,
I need calendar in my app, and I do not allow user to select the date before the specific date, such as, the user is not allowed to select the date in the past. how do I achieve that? please help.

Not Installing

I am not a newb.

Im getting these errors after using your bundle.

Ld build/Debug-iphonesimulator/Budget.app/Budget normal i386
cd /Users/Zaid/Desktop/BudgetingApp
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk -L/Users/Zaid/Desktop/BudgetingApp/build/Debug-iphonesimulator -F/Users/Zaid/Desktop/BudgetingApp/build/Debug-iphonesimulator -filelist /Users/Zaid/Desktop/BudgetingApp/build/BudgetingApp.build/Debug-iphonesimulator/BudgetingApp.build/Objects-normal/i386/Budget.LinkFileList -mmacosx-version-min=10.6 -all_load -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreData -framework QuartzCore /Users/Zaid/Desktop/klazuka-Kal-9464bf0/src/build/Debug-iphoneos/libKal.a -o /Users/Zaid/Desktop/BudgetingApp/build/Debug-iphonesimulator/Budget.app/Budget

ld: warning: in /Users/Zaid/Desktop/klazuka-Kal-9464bf0/src/build/Debug-iphoneos/libKal.a, missing required architecture i386 in file
Undefined symbols:
"OBJC_CLASS$_KalViewController", referenced from:
objc-class-ref-to-KalViewController in IncomeDetailsViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

"_OBJC_CLASS_$_KalViewController", referenced from: KalView Controller

Hi,
Below is the error i am facing while adding
KalViewController *calendar = [[KalViewController alloc] init];
[self.navigationController pushViewController:calendar animated:YES];
[self presentModalViewController:calendar animated:YES];

in my HolidayViewController.

I am developing iPad app.
App Flow is TabbedView --> Navigation View --> HolidayViewController(getting error)

Ld /Users/administrator/Library/Developer/Xcode/DerivedData/SharepointService-guwelsiocbugkkbrujsligcyzrsp/Build/Products/Debug-iphonesimulator/SharepointService.app/SharepointService normal i386
cd /Users/Raji/Development/SharepointTest/SharepointService
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/administrator/Library/Developer/Xcode/DerivedData/SharepointService-guwelsiocbugkkbrujsligcyzrsp/Build/Products/Debug-iphonesimulator -F/Users/administrator/Library/Developer/Xcode/DerivedData/SharepointService-guwelsiocbugkkbrujsligcyzrsp/Build/Products/Debug-iphonesimulator -filelist /Users/administrator/Library/Developer/Xcode/DerivedData/SharepointService-guwelsiocbugkkbrujsligcyzrsp/Build/Intermediates/SharepointService.build/Debug-iphonesimulator/SharepointService.build/Objects-normal/i386/SharepointService.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework CoreData -lsqlite3.0 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/administrator/Library/Developer/Xcode/DerivedData/SharepointService-guwelsiocbugkkbrujsligcyzrsp/Build/Products/Debug-iphonesimulator/SharepointService.app/SharepointService

Undefined symbols for architecture i386:
"OBJC_CLASS$_KalViewController", referenced from:
objc-class-ref in HolidayViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

kal showing wrong selected date (day light saving)

Today i noticed that when i select todays date in kal the -selectedDate is returned as yesterday 11pm.

Investigating further this is the case for any date after 27th March 2011. In the UK, this was the date when clocks went forward and it seems that kal does not take that in to effect.

Is there an easy way for me to alter kal's logic to take the day light saving in to account when returning selectedDate. thanks

The animation 's gone

This code is great,but one problem comes out when I use it.

ScheduleCalendarViewController *calendar=[[[ScheduleCalendarViewController alloc] initWithDataSource:[ArrangementDataSource dataSource]]autorelease];

calendar.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:calendar animated:YES];

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(addArrangement:) 
                                             name:@"addArrage" object:nil];

when I press the back button driectly with out doing anything on the calendar view . The animation has gone ,all my views in the program will not show any animation. but when I press the follow month button or previous month button it will be OK ,the animation comes back.

I don't konw it's my wrong using or some bug in the code .

Kal Date Format

The date in shortened format is displaying as: yyyy-mm-dd and when clicked I get scroller-selectors in dd-mm-yyyy pop up.

is it possible to change the shortened view to dd-mm-yyyy ?

Many thanks in advance for any help!

Pablo

Start day of the week

How to switch the start day(monday/sunday) using code? (not by changing in the settings to france).

ios 4 selected date

Since ios 4 has multitasking, any app won't shut down but stay in background. So in case of kal, if the app is first launched on August 6, then kal highlights the 6th of August with a certain background. Now if the user closes the app and opens the app on 7th of August, the highlight is still on the 6th of August. Using [kal showAndSelectDate:[NSDate date]] will now result in 6th and 7th both being highlighted with different backgrounds.

To recreate the bug:

  1. Open an app with kal.
  2. Close the app.
  3. Change the date of iphone to a future date.
  4. Open the app again.

Crash when displaying the month of April, 1995

Hello,

I am using the Kal lib in my application. When the month of April 1995 is displayed on the calendar, the app crashes. This is the stack trace:

Thread 0 Crashed:
0 libSystem.B.dylib 0x0007e98c __kill + 8
1 libSystem.B.dylib 0x0007e97c kill + 4
2 libSystem.B.dylib 0x0007e96e raise + 10
3 libSystem.B.dylib 0x0009361a abort + 34
4 libstdc++.6.dylib 0x000453b0 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x00005858 _objc_terminate + 104
6 libstdc++.6.dylib 0x00043776 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x000437ca std::terminate() + 10
8 libstdc++.6.dylib 0x00043896 __cxa_throw + 74
9 libobjc.A.dylib 0x00004714 objc_exception_throw + 64
10 CoreFoundation 0x00026b86 +[NSException raise:format:arguments:] + 74
11 CoreFoundation 0x00026b24 +[NSException raise:format:] + 28
12 Foundation 0x000208cc _NSArrayRaiseBoundException + 68
13 Foundation 0x00045ca8 -[NSCFArray objectAtIndex:] + 48
14 MyApp [KalMonthView showDates:leadingAdjacentDates:trailingAdjacentDates:]

I have done some debugging and it seems that for the month of April 1995, the method daysInFinalWeekOfPreviousMonth from KalLogic returns an array containing 13 elements ! This happens when having the iPhone's Region Format set to United States.

This happens also in HolidaysDemo project.

Hope this helps.

Thank you.

PS: please excuse my English. I'm not a native speaker :)

can we update kal liberary

Hi,
Can we add new methods in Kal Library or can I update/override any existing method. If so then please tell me the process.

Thanks in advance
Pankaj Nigam

new feature: toggle calendar

need a button to toggle the calendar up/down to have more room in the tableview.

would like to make this myself.

so three questions:

  • your opinion on: is this possible with Kal
  • if yes: do you have some hints for me (where to start, how it could work, any thoughts)
  • would you like a pull request to add this upstream?

regards,
klemens

Selecting todays date

I have created a button that when selected, acts as if the user tapped todays date tile. If todays date is not within the current month I get error

Assertion failure in -[KalMonthView tileForDate:]

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to find corresponding tile for date

This is how I am implementing
[(KalView *)[self.view viewWithTag:3] selectDate:[KalDate dateFromNSDate:[NSDate date]]];

I was wondering if there is some way to check if todays date is not in the current month, and if not load that month.

Holidays don't appear to load from sqlite db.

I have the Holiday example working (apparently fine) but no dots show up on any of the days, and nothing ever appears in the table view. The debugger says that the program is "Fetching holidays from the database between..." and I've added some logging statements inside that method that tell me it is getting into the IF and WHILE portions, but nothing shows up. The "holidays.db" file is in the Resources folder. Not sure where to look next...

What to do when Sunday is not the first day?

Your component seems very interesting especially given that you draw it instead of using subviews. But the only problem I have with it is that where I live, Monday is usually the first day of the week instead of Sunday. Is there any way to configure KalViewController so that it uses Monday as the first day of the week?

how to create datasource for kal

HI,
Can you please give a sample implementation that how to create the Datasource protocol for kal source code, so that i can include like this

id source = [[MyKalDataSource alloc] init];
KalViewController *calendar = [[[KalViewController alloc] initWithDataSource:source] autorelease];
[self.navigationController pushViewController:calendar animated:YES];

please can you give implementation for MyKalDataSource protocol

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.