有关ngui grid中去除一项后的排序问题
遇到这个问题,是在实现一个公告栏界面的时候,公告栏可以新增一条公告,也可以删除一条公告。
新增很简单,这里不做多的介绍;
关于删除,之前的代码是:
GameObject go = is_parent.transform.FindChild(name).gameObject;
UIGrid grid = is_parent.GetComponent<UIGrid>();
Destroy(go);
grid.Reposition();
但是没有效果,选择任何排序模式都没效果。一直都是在grid中有一个 单元元素大小的 空缺位置。
随后百度n次之后,有人说使用 grid.repositionNow = true;
随后代码为:
GameObject go = is_parent.transform.FindChild(name).gameObject;
UIGrid grid = is_parent.GetComponent<UIGrid>();
Destroy(go);
grid.repositionNow = true;
依然无效,很是纠结。
最终一想,这里的销毁只是销毁当前 单元元素对象,并没有在grid中做处理,换而言之,grid中还是把这个删除的元素当做正常存在的元素在处理,有了这个想法之后,代码就成了现在这个样子:
GameObject go = is_parent.transform.FindChild(name).gameObject;
UIGrid grid = is_parent.GetComponent<UIGrid>();
grid.RemoveChild(go.transform);
Destroy(go);
grid.sorting = UIGrid.Sorting.Vertical;
grid.repositionNow = true;
先在grid中移除当前元素
再销毁这个元素
最后设置排序(在前面的几种方案中,设置排序是在面板上做的。)
最后刷新排序
OK!
到这里算是完整结束了,希望能帮助到遇到这个问题正在找方法的人。
有关ngui grid中去除一项后的排序问题的更多相关文章
- [LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- [LeetCode] 26. Remove Duplicates from Sorted Array 有序数组中去除重复项
Given a sorted array nums, remove the duplicates in-place such that each element appear only once an ...
- [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项 II
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...
- 对Java数组中去除重复项程序分析
我作为一个Java菜鸟,只会用简单的办法来处理这个问题.如果有大神看到,请略过,感激不尽! 所以首先先分析这道题目:数组中重复的数据进行删除,并且要让数组里的数据按原来的顺序排列,中间不能留空. 既然 ...
- [LeetCode] Remove Duplicates from Sorted Array II 有序数组中去除重复项之二
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For exampl ...
- LeetCode 83. Remove Duplicates from Sorted List (从有序链表中去除重复项)
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项之二
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...
- 关于layui中tablle 渲染数据后 sort排序问题
最近在使用easyweb框架做后台管理,案例可见https://gitee.com/whvse/EasyWeb. 其中遇到了 sort排序问题, html代码:<table class=&quo ...
- [LeetCode] 26. Remove Duplicates from Sorted Array ☆(从有序数组中删除重复项)
[LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项 描述 Given a sorted array nums, remove the d ...
随机推荐
- keyword模块
导入关键字模块 import keyword 列出当前系统中Python的关键字 >>> keyword.kwlist ['and', 'as', 'assert', 'break' ...
- jsfl 读取xml
var fileURI = "file:///c|/temp/mydata.txt"; var dataXml = new XML(FLfile.read(fileURI)); v ...
- qurtz.net(转载)
Quartz+TopShelf实现Windows服务作业调度 Quartz:首先我贴出来了两段代码(下方),可以看出,首先会根据配置文件(quartz.config),包装出一个Quartz.Co ...
- 侧边栏收起展开效果,onmouseover,onmouseout
//方法一<!doctype html> <html lang="en"> <head> <meta charset="UTF- ...
- Android中查看SQLite中字段数据的两种方式
方式一:ADB Pull 通过adb pull导出*.db文件到PC的文件夹中,通过可视化工具 SQLiteExpertPers 进行查看.编辑: adb pull /data/data/com.jo ...
- easyui-datebox 只能获取当前日期以前的日期
<td> <input id="happenTimes" name="happenTimes" class="easyui-date ...
- idea git 发起一个pull request 请求
- C# 使用post的方式提交raw格式的数据,数据为json格式,多层嵌套
原文地址:https://cnodejs.org/topic/539ff8a5c3ee0b5820938d60 raw方式使用的是纯字符串的数据上传方式,所以在POST之前,可能需要手工的把一些JSO ...
- C# HttpWebRequest 错误总结
1.form data 需要编码!!! byte[] data = new ASCIIEncoding().GetBytes("pattern=0&wwid=古兴越&good ...
- 吴裕雄 19-Mysql 连接的使用
JOIN 按照功能大致分为如下三类:INNER JOIN(内连接,或等值连接):获取两个表中字段匹配关系的记录.LEFT JOIN(左连接):获取左表所有记录,即使右表没有对应匹配的记录.RIGHT ...