gpt4 book ai didi

iphone - 如何将复选框添加到 uialertview 中?

转载 作者:行者123 更新时间:2023-12-03 20:51:09 25 4
gpt4 key购买 nike

我是 iPhone 开发新手。我想在警报 View 中添加一个复选框。过去两天我正在对此警报 View 进行测试,但没有得到任何有效的演示项目。我正是想要这个警报框!

enter image description here

谁能帮我吗?

最佳答案

尝试使用此代码在 alertview 中添加复选框。

swift

let nameField = UIButton(frame: CGRect(x: 0.0, y: 0, width: 50, height: 50.0))
let v = UIView(frame: CGRect(x: 0, y: 0, width: 250, height: 40))
nameField.setImage(UIImage(named: "checkbox_off.png"), for: .normal)
v.addSubview(nameField)
var av = UIAlertView(title: "TEST", message: "subview", delegate: nil, cancelButtonTitle: "NO", otherButtonTitles: "YES")
av.setValue(v, forKey: "accessoryView")
av.show()

objective-c

UIButton *nameField = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0, 50, 50.0)];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, 40)];
[nameField setImage:[UIImage imageNamed:@"checkbox_off.png"] forState:UIControlStateNormal];
[v addSubview:nameField];
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"subview" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[av setValue:v forKey:@"accessoryView"];
[av show];

我希望这段代码对您有用。

关于iphone - 如何将复选框添加到 uialertview 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22727842/

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