当前位置: 首页>>代码示例>>C#>>正文


C# UITableViewCell.AddSubviews方法代码示例

本文整理汇总了C#中UITableViewCell.AddSubviews方法的典型用法代码示例。如果您正苦于以下问题:C# UITableViewCell.AddSubviews方法的具体用法?C# UITableViewCell.AddSubviews怎么用?C# UITableViewCell.AddSubviews使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UITableViewCell的用法示例。


在下文中一共展示了UITableViewCell.AddSubviews方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCell

            public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
            {
                if (indexPath.Section == 0) {
                    var infocell = new UITableViewCell ();
                    if (controller._controllerMode == 2) {
                        var inform = AppApi.GetSheets ().DataStudent.First (x => x.Id == editModel.SheetId);
                        //Customizing the progress bar
                        float sumWordAnswers = inform.Bad + inform.Good + inform.Nearly + inform.No;
                        var customProgressBar = UICustomProgressBar.Create ();
                        customProgressBar.Frame = new System.Drawing.RectangleF (10, 40, UIScreen.MainScreen.Bounds.Width-20, 4);
                        var width = customProgressBar.Frame.Width;
                        var height = customProgressBar.Frame.Height;

                        if (sumWordAnswers != 0) {

                            var badWidth = (inform.Bad / sumWordAnswers) * width;
                            var goodWidth = (inform.Good / sumWordAnswers) * width;
                            var noWidth = (inform.No / sumWordAnswers) * width;
                            var nearlyWidth = (inform.Nearly / sumWordAnswers) * width;

                            customProgressBar.ProgressBarRed = new System.Drawing.RectangleF (0, 2, badWidth, height);
                            customProgressBar.ProgressBarYellow = new System.Drawing.RectangleF (badWidth, 2, nearlyWidth, height);
                            customProgressBar.ProgressBarGreen = new System.Drawing.RectangleF (badWidth + nearlyWidth, 2, goodWidth, height);
                            customProgressBar.ProgressBarSilver = new System.Drawing.RectangleF (badWidth + nearlyWidth + goodWidth, 2, noWidth, height);

                        } else {
                            customProgressBar.ProgressBarRed = new System.Drawing.RectangleF (0, 0, 0, 0);
                            customProgressBar.ProgressBarYellow = new System.Drawing.RectangleF (0, 0, 0, 0);
                            customProgressBar.ProgressBarGreen = new System.Drawing.RectangleF (0, 0, 0, 0);
                            customProgressBar.ProgressBarSilver = new System.Drawing.RectangleF (0, 0, width, height);
                        }
                        infocell.AddSubview (customProgressBar);
                    } else {
                        UITextField title = new UITextField (new System.Drawing.RectangleF (15, 35, UIScreen.MainScreen.Bounds.Width - 130, 20));
                        title.Placeholder = "Введите название";
                        title.BorderStyle = UITextBorderStyle.RoundedRect;
                        if (editModel != null)
                            title.Text = editModel.Name;

                        UIButton save = new UIButton (new System.Drawing.RectangleF (title.Frame.Right + 5, 35, 100, 20));
                        save.SetTitle ("Сохранить", UIControlState.Normal);
                        save.BackgroundColor = UIColor.FromRGB (15, 83, 250);

                        save.TouchUpInside += (object sender, EventArgs e) => {

                        };

                        infocell.AddSubviews (new UIView[]{ title, save });
                    }

                    return infocell;
                }

                var cell = UIWordEdit.Create (); //tableView.DequeueReusableCell (UIWordEdit.Key, indexPath) as UIWordEdit;
                // if there are no cells to reuse, create a new one
                //if (cell == null)
                //	cell = new UIListWordCell (UITableViewCellStyle.Default, cellIdentifier);

                var oneItem = model.Data [indexPath.Row];
                cell.Id = oneItem.Id;
                cell.Russian = oneItem.Russian;
                cell.Transcr = oneItem.Transcription;
                cell.Example = oneItem.Description;
                cell.English = oneItem.English;
                cell.EditBtmEvent = (object sender, EventArgs e) => {
                    controller.Edit (model.Data [indexPath.Row]);
                };
                cell.DelBtmEvent = (object sender, EventArgs e) => {
                    if (!AppApi.DeleteWord (model.Data [indexPath.Row].Id))
                        return;
                    model.Data.RemoveAt (indexPath.Row);
                    tableView.DeleteRows (new NSIndexPath[]{ indexPath }, UITableViewRowAnimation.Fade);
                };

                if (controller._controllerMode == 2)
                    cell.DisableControls = true;

                return cell;
            }
开发者ID:raskarov,项目名称:wordzilla_xamarin,代码行数:79,代码来源:EditWordsController.cs


注:本文中的UITableViewCell.AddSubviews方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。