gpt4 book ai didi

ios - 自定义警报 View Controller 以在 IOS 中选择日期

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:08:34 24 4
gpt4 key购买 nike

<分区>

我有一个自定义警报 View Controller 来从日期选择器中选择日期,但我有点困惑我如何在警报 View Controller 中添加两个按钮以及当用户单击该按钮时它会在警报 View Controller 中显示日期选择器以及如何更改警报 View Controller 的颜色。我的代码是,

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIDatePicker *picker = [[UIDatePicker alloc] init];
[picker setDatePickerMode:UIDatePickerModeDate];
[alertController.view addSubview:picker];
[alertController addAction:({
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"OK");
NSLog(@"%@",picker.date);
}];
action;
})];
UIPopoverPresentationController *popoverController = alertController.popoverPresentationController;
popoverController.sourceView = sender;
popoverController.sourceRect = [sender bounds];
[self presentViewController:alertController animated:YES completion:nil];

看起来像这样, enter image description here

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com