如何在uialertview中添加复选框? [英] how to add checkbox into uialertview?
本文介绍了如何在uialertview中添加复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是iPhone开发的新手.我想在警报视图中添加一个复选框.我过去两天都在此Alertview上进行测试,但没有任何有效的演示项目.我正是想要这个警报框!
I'm new in iPhone development. I want to add a check box into an alert view. I'm doing tests on this alertview for the last two days, but do not get any working demo project. I want exactly this alertbox!
有人可以帮助我吗?
推荐答案
尝试使用此代码在 alertview
中添加复选框.
try this code for add checkbox in alertview
.
快速
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()
目标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];
我希望这段代码对您有用.
i hope this code useful for you.
这篇关于如何在uialertview中添加复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文