Пример #1
0
        /**
         * Returns an existing cell at a given index. Returns nil if a cell is nonexistent at the moment of query.
         *
         * @param idx index
         * @return a cell at a given index
         */
        public CCTableViewCell CellAtIndex(int idx)
        {
            CCTableViewCell found = null;

            if (m_pIndices.Contains(idx))
            {
                found = (CCTableViewCell)m_pCellsUsed.ObjectWithObjectID(idx);
            }

            return(found);
        }
Пример #2
0
        /**
         * Inserts a new cell at a given index
         *
         * @param idx location to insert
         */

        public void InsertCellAtIndex(int idx)
        {
            if (idx == CCArrayForObjectSorting.CC_INVALID_INDEX)
            {
                return;
            }

            var uCountOfItems = m_pDataSource.NumberOfCellsInTableView(this);

            if (uCountOfItems == 0 || idx > uCountOfItems - 1)
            {
                return;
            }

            int newIdx;
            var cell = (CCTableViewCell)m_pCellsUsed.ObjectWithObjectID(idx);

            if (cell != null)
            {
                newIdx = m_pCellsUsed.IndexOfSortedObject(cell);
                for (int i = newIdx; i < m_pCellsUsed.Count; i++)
                {
                    cell = (CCTableViewCell)m_pCellsUsed[i];
                    _setIndexForCell(cell.Index + 1, cell);
                }
            }

            //   [m_pIndices shiftIndexesStartingAtIndex:idx by:1];

            //insert a new cell
            cell = m_pDataSource.TableCellAtIndex(this, idx);
            _setIndexForCell(idx, cell);
            _addCellIfNecessary(cell);

            _updateContentSize();
        }