1

GDataを使用してiPhoneにGoogleカレンダーグリッドビューリンクを実装したい。そのため、GDataを介してGoogleアカウントを正常に実装し、アクセスしました。しかし、TableView構造ですべてのイベントを見ることができます...次のスクリーンショットのような構造が必要です。

ここに画像の説明を入力してください

このビューを取得するにはどうすればよいですか?

このリンクからデモアプリをダウンロードしました。

4

1 に答える 1

2

こんにちは、そのようなカレンダーを表示するためのサードパーティ API が 1 つあります..

ここにいくつかのコードを示します

週の実装、

- (MAEvent *)event {
static int counter;

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

[dict setObject:[NSString stringWithFormat:@"number %i", counter++] forKey:@"test"];

MAEvent *event = [[MAEvent alloc] init];
event.backgroundColor = [UIColor purpleColor];
event.textColor = [UIColor whiteColor];
event.allDay = NO;
event.userInfo = dict;
return event;
}


- (void)weekView:(MAWeekView *)weekView eventTapped:(MAEvent *)event {
NSDateComponents *components = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:event.start];
NSString *eventInfo = [NSString stringWithFormat:@"Hour %i. Userinfo: %@", [components hour], [event.userInfo objectForKey:@"test"]];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:event.title
                                                 message:eventInfo delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}

Day.. tatic NSDate *date = nil; の実装。

- (NSArray *)dayView:(MADayView *)dayView eventsForDate:(NSDate *)startDate 
{
date = startDate;

NSArray *arr = [NSArray arrayWithObjects: self.event, self.event, self.event,
                self.event, self.event, self.event, self.event,  self.event, self.event, nil];
static size_t generateAllDayEvents;

generateAllDayEvents++;

if (generateAllDayEvents % 4 == 0)
{
    ((MAEvent *) [arr objectAtIndex:0]).title = @"All-day events test";
    ((MAEvent *) [arr objectAtIndex:0]).allDay = YES;
    ((MAEvent *) [arr objectAtIndex:1]).title = @"All-day events test";
    ((MAEvent *) [arr objectAtIndex:1]).allDay = YES;
}
return arr;
}

 - (MAEvent *)event {
static int counter;
static BOOL flag;

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

[dict setObject:[NSString stringWithFormat:@"number %i", counter++] forKey:@"test"];

unsigned int r = arc4random() % 24;
int rr = arc4random() % 3;

MAEvent *event = [[MAEvent alloc] init];
event.backgroundColor = ((flag = !flag) ? [UIColor purpleColor] : [UIColor brownColor]);
event.textColor = [UIColor whiteColor];
event.allDay = NO;
event.userInfo = dict;

if (rr == 0) {
    event.title = @"Event lorem ipsum es dolor test. This a long text, which should clip the event view bounds.";
} else if (rr == 1) {
    event.title = @"Foobar.";
} else {
    event.title = @"Dolor test.";
}

NSDateComponents *components = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:date];
[components setHour:r];
[components setMinute:0];
[components setSecond:0];

event.start = [CURRENT_CALENDAR dateFromComponents:components];

[components setHour:r+rr];
[components setMinute:0];

event.end = [CURRENT_CALENDAR dateFromComponents:components];

return event;
 }
于 2012-08-13T07:30:06.613 に答える