アラートコントローラに日付パイーカーを追加しようとしましたが、サイズに問題があります。私は日付pikerの高さを取得する方法や日付pikerの高さを持つinit UIAlertControllerを知ることはできません。 だから、私がやった:UIAlertControllerにUIDatePickerを追加する方法iOS9
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"\n\n\n\n\n\n\n\n\n\n" preferredStyle:UIAlertControllerStyleActionSheet];
UIView *viewDatePicker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)];
[viewDatePicker setBackgroundColor:[UIColor clearColor]];
CGRect pickerFrame = CGRectMake(0, 0, self.view.frame.size.width, 200);
UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[picker setDatePickerMode:UIDatePickerModeTime];
[viewDatePicker addSubview:picker];
[alertController.view addSubview:viewDatePicker];
NSDateFormatter *formate=[[NSDateFormatter alloc]init];
[formate setDateFormat:@"hh:mm a "];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
sinceDateString = [formate stringFromDate:picker.date];
[sinceDateButton setTitle:sinceDateString forState:UIControlStateNormal];
}];
[alertController addAction:defaultAction];
[self presentViewController:alertController animated:YES completion:nil];
私はこの解決策を見つける同じ質問UIAlertController の1 * alertController = [UIAlertController alertControllerWithTitle:nilにメッセージ: "@ \ N \ N \ N \ N \ N \ N \ n \ n \ n \ n " preferredStyle:UIAlertControllerStyleActionSheet];
しかし、私は灰色の線が見えるので間違った解決策だと分かります。
これは現在選択されている日付の選択行です。 –
ありがとうございます。しかし、 "\ n \ n \ n"については、UIAlertControllerの高さを追加する唯一の解決策がありますか? –
\ nは新しい行を作成することを意味します –