Esempio n. 1
0
        /// <summary>
        /// Gets the cell.
        /// </summary>
        /// <returns>The cell.</returns>
        /// <param name="tableView">Table view.</param>
        /// <param name="indexPath">Index path.</param>
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            //get forms cell
            Cell cell = _settingsView.Model.GetCell(indexPath.Section, indexPath.Row);

            string id = cell.GetType().FullName;

            var renderer = (CellRenderer)Xamarin.Forms.Internals.Registrar.Registered.GetHandler <IRegisterable>(cell.GetType());

            //get recycle cell
            UITableViewCell reusableCell = tableView.DequeueReusableCell(id);
            //get native cell
            UITableViewCell nativeCell = renderer.GetCell(cell, reusableCell, tableView);

            UITableViewCell cellWithContent = nativeCell;

            // Sometimes iOS for returns a dequeued cell whose Layer is hidden.
            // This prevents it from showing up, so lets turn it back on!
            if (cellWithContent.Layer.Hidden)
            {
                cellWithContent.Layer.Hidden = false;
            }

            // Because the layer was hidden we need to layout the cell by hand
            cellWithContent?.LayoutSubviews();

            //selected background
            if (!(nativeCell is CellBaseView))
            {
                nativeCell.SelectionStyle = UITableViewCellSelectionStyle.None;
            }

            return(nativeCell);
        }