5

I am new to obj c and I am not understanding how to use Kal Calendar. Would anyone be willing to help a new app developer walk through the process? I have it installed to my app but don't know how to use it. I understand if you don't respond, I cant find any tutorials on it and google only helped a little.

I am using ios5, storyboards and arc. Thanks in advance.

I had to subclass the calendar with storyboards, is this the best way? I cant get it to display with a navbar any other way.

UPDATED-I don't think subclass is the way to go but I am still working on a solution

iDev
  • 23,310
  • 7
  • 60
  • 85
TIDev
  • 109
  • 4
  • 10

1 Answers1

6

I created a view controller to contain the calendar view controller(KalViewController). That view controller is the KalViewControllerDelegate and datasource. I add the KalViewController as a child view controller using the containment introduced on iOS 5. I added the parent view controller of the KalViewController to a popover controller (on an iPad application). I present it from where I wanted to (UIBarButtonItem). The job of the parent view controller is to provide dates for the calendar view, and to provide data to the table view.

Edit: Here's what you need to do:

on

- (void)presentingDatesFrom:(NSDate *)fromDate to:(NSDate *)toDate delegate:(id<KalDataSourceCallbacks>)delegate

You need to find your dates (Network, database, etc). Once you fetch the information containing the dates, you call [delegate loadedDataSource:self];

- (NSArray *)markedDatesFrom:(NSDate *)fromDate to:(NSDate *)toDate

This is to show the dates that are marked on the calendar (the ones with the little dot to mark an event on a particular day). Here you use the dates from your model to find the ones that are going to be visible on the calendar for a month.

- (void)loadItemsFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate

This will be called when the user selects a day of a month. This should be used to update the list of objects being shown on the tableview datasource. So, if you keep an array with the dates for the calendar table, update the array with the data for the given day.

and finally:

- (void)removeAllItems

clear your tableview datasource array.

You also have to implement the Calendar's tableview datasource and delegate methods.

J2theC
  • 4,412
  • 1
  • 12
  • 14
  • Are you saying I should look into the containment on iOS5? But my question origional question was how to implement it. I tried KalViewController *calendar = [[KalViewController alloc] init]; [self.navigationController pushViewController:calendar animated:NO]; But that gave me 2 view controllers. – TIDev Aug 24 '12 at 20:20
  • what gave you 2 view controllers? – J2theC Aug 24 '12 at 20:32
  • I created a view controller and tried to implement the kal controller in it, if the view controller is the kal view delegate, how do i Implement it? – TIDev Aug 25 '12 at 04:35
  • Ok, I got the Calendar displayed. How do I implement the datasource part based on the date pressed on the calendar? – TIDev Aug 25 '12 at 18:24
  • Better question, can you use NSJSON with Kal Calendar or do you have to use SBJson? – TIDev Aug 26 '12 at 01:03
  • NSJSON or SBJSON, it's just a way to serialize/deserialize JSON data under iOS, and it's makes no difference to the calendar. You need to provide the calendar with dates (NSDate objects), which is what is important to Kal. – J2theC Aug 27 '12 at 14:46
  • check my edited answer, since there is not much control for code on the comments. – J2theC Aug 27 '12 at 14:47
  • I had to subclass the calendar with sotryboards, is this the best way? I cant get it to display with a navbar any other way. – TIDev Aug 27 '12 at 15:28
  • I am still confused on KalDataSource protocol. – TIDev Aug 31 '12 at 01:47
  • @TIDev do you understand delegates and protocols? If not I'd read a bit about it. But basically, you need to tell Kal where to get it's data from. In order to do that, you declare a class to be a KalDataSource delegate and implement the KalaDataSource protocols. – ari gold Sep 08 '12 at 21:06
  • I got that done. For some reason I am not figuring out didselectrowatindexpath. – TIDev Sep 09 '12 at 01:17