有关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 ...
随机推荐
- 静态属性@property
property 作用其实把类里面的逻辑给隐藏起来(封装逻辑,让用户调用的时候感知不到你的逻辑) property实例1:class Room: def __init__(self): pass @p ...
- Oracle查询表结果添加到另一张表中
转自:https://blog.csdn.net/lx870576109/article/details/78336695 把每一个知识点进行积累:Oracle数据库中将查询一张表的结果添加到另一张表 ...
- Linux 远程登录配置
如果使用FlashFxp的sftp无法登陆,提示SSH 错误: 协商认证模式失败,也同样这样操作 修改你的ssh配置文件 配置文件路径如:/etc/ssh/sshd_config PasswordAu ...
- python_04 基本数据类型、数字、字符串、列表、元组、字典
基本数据类型 所有的方法(函数)都带括号,且括号内没带等号的参数需传给它一个值,带等号的参数相当于有默认值 1.数字 int 在32位机器上,整数的位数为32位,取值范围为-2**31-2**31-1 ...
- APP-5-百度电子围栏
1.代码部分 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <me ...
- iframe+form上传文件
<iframe id="iframe1" name="ifra1" style="display: none"></ifr ...
- 更改html代码后网页不更新
写了一个非常简单的 html 页面,只有简单的跳转功能,但是在 Eclipse 下更改代码后用 chrome 浏览器打开时还是显示原来的网页.开始我以为是网页有错误或者有不规范的地方,因为我编写的是 ...
- JAVA_Class.forName
Class.forName(xxx.xx.xx) 返回的是一个类 ,作用是要求JVM查找并加载指定的类,也就是说JVM会执行该类的静态代码段 --------- 首先,在java里面任何class都要 ...
- 把网卡中断绑定到CPU,最大化网卡的吞吐量(转)
先来看一下问题, 我们通过 ifconfig 查看接口的名称 为 p15p1, 一般机器为 eth0 再通过命令 ➜ ~ cat /proc/interrupts | head -n 1 && ...
- apache-php
1.安装apache https://www.cnblogs.com/lxlb/p/9159056.html 2.安装php https://www.cnblogs.com/37yan/p/68794 ...