有关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 ...
随机推荐
- PHP斐波那契数列
一个斐波那契数列的求法 1 1 2 3 5 8 13 21 34 55 要求写出算法 //数组法 function test($num){ $arr=[]; for($i=0;$i<=$nu ...
- container_of使用小结
先上演示代码 #include <stdio.h> #include <stdlib.h> /* offsetof example */ #include <stddef ...
- .net DLL 注册 regasm delphi调用
.net DLL 注册 regasm regasm regasm myTest.dll regasm.exe 打开vs2005自带的工具“Visual Studio 2005命令提示”,输入上述命令 ...
- Installing PHP5 on Ubuntu Server
When installing PHP 5 from source I ran into the following problems and solutions: Problem:configure ...
- C#--构造函数的理解
说白了构造函数就是用来初始化类的数据成员{因为C#语言具有类型安全的特质-->不能使用没有初始化的变量)} 在这里引用一下别人的总结,我觉得挺好的: 构造函数是一种特殊的成员函数,它主要用于为对 ...
- js 编写一个神奇的四则运算
写一个算法,有时候可以用简单的方法就可以写出来,但是只能针对特定的环境,如果要能够适应不同的环境,就需要对算法进行优化,在优化的过程中,你会觉得非常神奇,下面来看一个简单的四则运算的算法编写方式: 1 ...
- unity 解决ScrollRect嵌套滚动问题
在子级有ScrollRect组件的对象添加以下脚本: using UnityEngine; using System.Collections; using UnityEngine.UI; using ...
- How to Pronounce T + Dark L
How to Pronounce T + Dark L Share Tweet Share Tagged With: Dark L The T and Dark L combination is co ...
- 转: JQuery this和$(this)的区别及获取$(this)子元素对象的方法
1.JQuery this和$(this)的区别 相信很多刚接触JQuery的人,很多都会对$(this)和this的区别模糊不清,那么这两者有什么区别呢? 首先来看看JQuery中的 $() 这 ...
- 用Delphi制作DLL
一.开使你的第一个DLL专案 1.File->Close all->File->New﹝DLL﹞代码: //自动产生Code如下 library Project2; //这有段 ...