Xamarin.Ios 下拉菜单,多选,键盘弹出功能
来源:互联网 发布:js 私有函数 编辑:程序博客网 时间:2024/06/03 10:19
终于把这块弄完了,有兴趣的加我好友569653292
1、首先要键盘弹出一个下拉菜单,要知道ios没有下拉菜单这个说法,我们可以按照datePickerView的方式给它自定义,或者用tableview,这篇文章主要说一下用tableview的多选功能,先上图
好了,就是这个样子了,先定义一个tableview
UITableView utv = new UITableView (View.Bounds);
utv.AutoresizingMask = UIViewAutoresizing.All;
utv.Source=new myViewSource(list_leibie,ut_leibie);
ut_leibie.InputView=utv;//这行就可以把它当作键盘弹出了
private class myViewSource:UITableViewSource
{
private List<string> dupLeibie;
UITextField leibie_string = new UITextField ();
public myViewSource(List<string>prems,UITextField ut){
dupLeibie=prems;
leibie_string=ut;//传递进来一个uitextfield,不然在函数里面不能更改界面的东西
}
public override nint RowsInSection (UITableView tableview, nint section)
{
return dupLeibie.Count;//返回行数
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell theCell = new UITableViewCell ();
theCell.TextLabel.Text = dupLeibie [indexPath.Row];
theCell.TextLabel.Font = UIFont.SystemFontOfSize (15);
return theCell;//以上都是设置内容
}
string leibie = "";//用来设置文本框的内容
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
leibie = "";
int rowIndex = indexPath.Row;
UITableViewCell cellview = tableView.CellAt (indexPath);//当前行
//判断当前行是否有标记
if (cellview.Accessory == UITableViewCellAccessory.None) {
cellview.Accessory = UITableViewCellAccessory.Checkmark;
} else {
cellview.Accessory = UITableViewCellAccessory.None;
tableView.DeselectRow (indexPath, true);
}
//设置值,把选中的值加起来
for (nint i = 0; i<5; i++)
{
//NSIndexPath ina=tableView.cell
UITableViewCell cellview2 = tableView.VisibleCells[i];
//判断当前行是否有标记
if (cellview2.Accessory == UITableViewCellAccessory.Checkmark) {
if (leibie == "") {
leibie += cellview2.TextLabel.Text;
} else {
leibie += "," + cellview2.TextLabel.Text;
}
}
if (leibie == "") {
leibie = "选择回收类别";
}
}
leibie_string.Text = String.Format(leibie);
}
}
- Xamarin.Ios 下拉菜单,多选,键盘弹出功能
- IOS 实现键盘弹出视图上移功能
- IOS 实现键盘弹出视图上移功能
- Xamarin.ios 下拉刷新效果
- jquery弹出下拉菜单
- jquery 下拉弹出菜单
- 弹出菜单功能
- jQuery点击弹出下拉菜单
- jQuery点击弹出下拉菜单
- 鼠标悬停弹出下拉菜单
- iOS监听键盘弹出
- iOS 键盘弹出效果
- iOS wkwebview 弹出键盘
- Xamarin.iOS 下拉刷新样式的修改
- Xamarin.iOS 自定义样式的弹出窗
- android弹出下拉选择菜单,单选,多选
- iOS tableView多选,长按弹出菜单
- iOS实现下拉菜单
- linux sed命令详解
- ios图形上下文CGContext
- 安装搜狗输入法
- MFC 控件变量数据交换
- 选择排序---堆排序算法(Javascript版)
- Xamarin.Ios 下拉菜单,多选,键盘弹出功能
- Scaler算法小结
- Dijkstra 邻接矩阵 单源点最短路径
- scrapy 抓取豆瓣数据(1)
- Facebook pop
- RMI CORBA AIDL IPC RPC 之间的关系
- 09-Dom操作复选框(全选、全不选、反选)
- All is about C!
- SpringAOP切入点表达式