Hatena::ブログ(Diary)

24/7 twenty-four seven Twitter

東日本大震災緊急支援募金募集中。国際NGOワールド・ビジョン・ジャパン

Bloglinesで閲読登録 ADD TO Hatena::RSS Subscribe with livedoor Reader Add to Google

mail address

Follow me on twitter.

iPhone アプリケーション

Hatena touch LDR touch TV Listings LCD Clock MyWebClip MyWebClip LITE  Japan Subway Route Map こころくろっく 英辞郎 on the WEB for iPhone(アルク)
i-Radio くるりんぱ性格診断 英辞郎検索ランキング(アルク) kotobank - コトバンク miil

iPad アプリケーション

LCD Clock HD 「超」整理手帳 for the iPad

共著

2008-12-28

UICCalendarPickerの使い方

基本形

UICCalendarPicker *calendarPicker = [[UICCalendarPicker alloc] initWithSize:UICCalendarPickerSizeMedium];
[calendarPicker setDelegate:self];
[calendarPicker setSelectionMode:UICCalendarPickerSelectionModeMultiSelection];
[calendarPicker showInView:self.view animated:YES];
[calendarPicker release];
1. サイズを指定してインスタンスを作ります。
UICCalendarPicker *calendarPicker = [[UICCalendarPicker alloc] initWithSize:UICCalendarPickerSizeMedium];
2. デリゲートを設定します。
[calendarPicker setDelegate:self];
3. 選択モードを設定します。

単一選択: UICCalendarPickerSelectionModeSingleSelection

複数選択: UICCalendarPickerSelectionModeMultiSelection

範囲選択: UICCalendarPickerSelectionModeRangeSelection

[calendarPicker setSelectionMode:UICCalendarPickerSelectionModeMultiSelection];

デリゲート・メソッド

ボタン(「閉じる」「先月」「来月」「日付」)を押したとき、対応したメソッドが呼ばれます。

@protocol UICCalendarPickerDelegate<NSObject>
@optional
- (void)picker:(UICCalendarPicker *)picker pushedCloseButton:(id)sender;
- (void)picker:(UICCalendarPicker *)picker pushedPrevButton:(id)sender;
- (void)picker:(UICCalendarPicker *)picker pushedNextButton:(id)sender;
- (void)picker:(UICCalendarPicker *)picker didSelectDate:(NSArray *)selectedDate;
@end

データソース・メソッド

日付の属性によって、外観をカスタマイズします。

@protocol UICCalendarPickerDataSource<NSObject>
@optional
- (NSString *)picker:(UICCalendarPicker *)picker textForYearMonth:(NSDate *)aDate;
- (void)picker:(UICCalendarPicker *)picker buttonForDateToday:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDateWeekday:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDateSaturday:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDateSunday:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDateMonthOut:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDateOutOfRange:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDateSelected:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDateBlank:(UICCalendarPickerDateButton *)button;
- (void)picker:(UICCalendarPicker *)picker buttonForDate:(UICCalendarPickerDateButton *)button;
@end

例えば、土曜日だけ別のボタンにするには次のようにします。

- (void)picker:(UICCalendarPicker *)picker buttonForDateSaturday:(UICCalendarPickerDateButton *)button {
	[button setBackgroundImage:[UIImage imageNamed:@"uiccalendar_cell_custom1.png"] forState:UIControlStateNormal];
}

iPhone用日付選択UIライブラリ、UICCalendarPickerを作りました。 - 24/7 twenty-four seven

katukatu 2010/02/03 15:30 突然失礼いたします。UICCalenderPickerは初期で開いた状態では本日の日付にカーソルがあたっている仕様になっているようなのですが、これを初期より指定した日付データを元にカーソルを当てる方法はないのでしょうか?

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証