有关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 ...
随机推荐
- Appium -选择、操作元素
选择界面元素 操作元素(点击.输入字符.拖拽.获取页面元素的各种属性) 根据Appium获取的数据进行分析和处理 desired_capabilities 查看appPackage 和appActiv ...
- react-native react-navigation StackNavigator android导航栏 标题下居中
navigationOptions:({ navigation }) => ({ , textAlign:'center' }}) 如上设置即可,如果有返回箭头,那么右边也要加一个 占位的或者设 ...
- 深度学习原理与框架-卷积网络细节-经典网络架构 1.AlexNet 2.VGG
1.AlexNet是2012年最早的第一代神经网络,整个神经网络的构架是8层的网络结构.网络刚开始使用11*11获得较大的感受野,随后使用5*5和3*3做特征的提取,最后使用3个全连接层做得分值得运算 ...
- ABAP-折叠窗口
1.测试 2.代码 *&---------------------------------------------------------------------* *& Report ...
- 130. Surrounded Regions 卧槽!我半梦半醒之间做出来的。
打开这个题,做了一半躺下了. 结果,怎么都睡不着.一会一个想法,忍不住爬起来提交,要么错误,要么超时. 按照常规思路,依次对每个点检测是否是闭包,再替换,超时.计算量太大了. 还能怎么做呢?没思路,关 ...
- ubuntu oracle 环境搭建
安装 Oracle SQL Developer Oracle客户端安装 https://oracle.github.io/odpi/doc/installation.html#linux
- suse 关于使用 /etc/init.d/boot.local的问题
最近看了一个问题,有同事在 suse环境下的/etc/init.d/boot.local 中,增加了一行脚本. 该脚本的简单大意如下: #!/bin/bash ] do ] then echo &qu ...
- [jQ]使用jQuery将多条数据插入模态框的方法
---------------------------------------------------------------------------------------------------- ...
- python常用字符串处理(转)
转自https://www.cnblogs.com/houht/p/3308634.html 判断字符串str是否为空 Approach 1:如果字符串长度为0,说明字符串为空,code如下: isN ...
- 重装unbantu 问题集合,下载别人的代码运行问题集合
安装angular 的时候要全局设置 npm install -g angular-cli nodemon server.js 出现[nodemon] Internal watch failed:xx ...