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


C# UITextField.SetDidChangeNotification方法代码示例

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


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

示例1: TableSource

            public TableSource()
            {
                expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel>();

                categoryCell = new UITableViewCell (UITableViewCellStyle.Default, null);
                categoryCell.TextLabel.Text = "Category";
                categoryCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                categoryCell.AccessoryView = category = new UILabel (new CGRect(0f, 0f, 200f, 36f)) {
                    TextAlignment = UITextAlignment.Right,
                    BackgroundColor = UIColor.Clear,
                };

                costCell = new UITableViewCell (UITableViewCellStyle.Default, null);
                costCell.TextLabel.Text = "Cost";
                costCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                costCell.AccessoryView = cost = new UITextField(new CGRect (0f, 0f, 200f, 36f))
                {
                    VerticalAlignment = UIControlContentVerticalAlignment.Center,
                    TextAlignment = UITextAlignment.Right,
                };
                cost.SetDidChangeNotification (c =>
                {
                    string text = c.Text.Replace ("$", string.Empty);
                    decimal value;
                    expenseViewModel.SelectedExpense.Cost = decimal.TryParse (text, out value) ? Math.Abs (value) : 0;
                });

                descriptionCell = new UITableViewCell (UITableViewCellStyle.Default, null) {
                    SelectionStyle = UITableViewCellSelectionStyle.None
                };
                descriptionCell.AccessoryView = description = new PlaceholderTextView (new CGRect (0f, 0f, Theme.IsiOS7 ? 515f : 470f, 90f)) {
                    BackgroundColor = UIColor.Clear,
                    Placeholder = "Please enter notes here",
                };
                description.SetDidChangeNotification (d =>
                    expenseViewModel.SelectedExpense.Description = description.Text != description.Placeholder ? d.Text : string.Empty
                );

                photoCell = new UITableViewCell(UITableViewCellStyle.Default, null) {
                    SelectionStyle = UITableViewCellSelectionStyle.None
                };

                photoButton = UIButton.FromType (UIButtonType.Custom);
                photoButton.SetBackgroundImage (Theme.AddPhoto, UIControlState.Normal);
                photoButton.SetTitle ("Add Photo", UIControlState.Normal);
                photoButton.SetTitleColor (Theme.LabelColor, UIControlState.Normal);
                photoButton.ContentEdgeInsets = new UIEdgeInsets (0f, 0f, 2f, 0f);
                photoButton.Frame = new CGRect (210f, 130f, 115f, 40f);
                photoButton.TouchUpInside += (sender, e) => {
                    if (photoSheet == null) {
                        photoSheet = new PhotoAlertSheet();

                        //Set the desired size for the resulting image
                        var size = photo.Frame.Size;
                        var scale = UIScreen.MainScreen.Scale;
                        size.Width *= scale;
                        size.Height *= scale;
                        photoSheet.DesiredSize = size;

                        //Set the callback for when the image is selected
                        photoSheet.Callback = image => {
                            if (expenseViewModel.Photo == null)
                                expenseViewModel.Photo = new ExpensePhoto { ExpenseId = expenseViewModel.SelectedExpense.Id };

                            expenseViewModel.Photo.Image = image.ToByteArray ();
                            Load (enabled);
                        };
                    }
                    photoSheet.ShowFrom (photoButton.Frame, photoCell, true);
                };
                photoCell.AddSubview (photoButton);
                var frame = photoCell.Frame;
                frame.X = 18f;
                frame.Width -= 34f;

                photo = new UIImageView (frame) {
                    AutoresizingMask = UIViewAutoresizing.All,
                    ContentMode = UIViewContentMode.ScaleAspectFit
                };

                photo.Layer.BorderWidth = 1f;
                photo.Layer.BorderColor = new CGColor (0xcf, 0xcf, 0xcf, 0x7f);
                photo.Layer.CornerRadius = 10f;
                photo.Layer.MasksToBounds = true;
                photoCell.AddSubview (photo);
            }
开发者ID:tranuydu,项目名称:prebuilt-apps,代码行数:86,代码来源:AddExpenseController.cs


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