protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (TokenField != null)
                {
                    TokenField.Dispose();
                    TokenField = null;
                }
                CustomGetCellHeightMethod = null;
                CustomGetCellMethod = null;
                CustomTableView = null;
                if (_popoverController != null)
                {
                    _popoverController.Dispose();
                    _popoverController = null;
                }
                if (_tokenDelegateShim != null)
                {
                    _tokenDelegateShim.Dispose();
                    _tokenDelegateShim = null;
                }
                if (_tableViewDelegateShim != null)
                {
                    _tableViewDelegateShim.Dispose();
                    _tableViewDelegateShim = null;
                }
                if (_tableViewDataSource != null)
                {
                    _tableViewDataSource.Dispose();
                    _tableViewDataSource = null;
                }

                if (Separator != null)
                {
                    Separator.Dispose();
                    Separator = null;
                }

                if (ContentView != null)
                {
                    ContentView.Dispose();
                    ContentView = null;
                }
            }
            base.Dispose(disposing);
        }
        protected virtual void Setup()
        {
            _tokenDelegateShim = new TITokenFieldDelegateShim(this);
            _tableViewDelegateShim = new TableViewDelegateShim(this);
            _tableViewDataSource = new TableViewDataSourceShim(this);

            this.BackgroundColor = UIColor.Clear;
            this.DelaysContentTouches = true;
            this.MultipleTouchEnabled = false;

            this.TokenField = new TITokenField()
            {
                Frame = new CGRect(0, 0, this.Bounds.Size.Width, 42)
            };

            this.ShowAlreadyTokenized = false;
            this.SearchSubtitles = true;
            this.ForcePickSearchResult = false;
            this.ResultsArray = new List<object>();

           
            this.TokenField.Started += tokenField_DidBeginEditing;
            this.TokenField.Ended += tokenField_DidEndEditing;
            this.TokenField.EditingChanged += tokenField_TextDidChange;

            this.TokenField.FrameDidChange += tokenField_FrameDidChange;

            this.TokenField.Delegate = _tokenDelegateShim;

            this.AddSubview(this.TokenField);

            nfloat tokenFieldBottom = this.TokenField.Frame.Bottom;

            this.Separator = new UIView(new CGRect(0, tokenFieldBottom, this.Bounds.Size.Width, 1));
            this.Separator.BackgroundColor = UIColor.FromWhiteAlpha(0.7f, 1f);

            // This view is created for convenience, because it resizes and moves with the rest of the subviews.
            this.ContentView = new UIView(new CGRect(0, tokenFieldBottom + 1, this.Bounds.Size.Width, this.Bounds.Size.Height - tokenFieldBottom - 1));
            this.ContentView.BackgroundColor = UIColor.Clear;
            this.AddSubview(this.ContentView);

            UITableView customTable = null;
            if (this.TokenField.Delegate != null)
            {
                customTable = this.TokenField.Delegate.GetCustomTableView(this.TokenField);
            }
            if (customTable != null)
            {
                this.ResultsTable = customTable;
                this.ResultsTable.Delegate = _tableViewDelegateShim;
                this.ResultsTable.DataSource = _tableViewDataSource;
                this.IsCustomResultsTable = true;
            }
            else
            {
                this.AddSubview(this.Separator);

                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    UITableViewController tableViewController = new UITableViewController(UITableViewStyle.Plain);
                    tableViewController.TableView.Delegate = _tableViewDelegateShim;
                    tableViewController.TableView.DataSource = _tableViewDataSource;
                    tableViewController.PreferredContentSize = new CGSize(400, 400);

                    this.ResultsTable = tableViewController.TableView;

                    _popoverController = new UIPopoverController(tableViewController);
                }
                else
                {

                    this.ResultsTable =  new UITableView(new CGRect(0, tokenFieldBottom + 1, this.Bounds.Size.Width, 10));
                    this.ResultsTable.SeparatorColor = UIColor.FromWhiteAlpha(0.85f, 1f);
                    this.ResultsTable.BackgroundColor = UIColor.FromRGBA(0.92f, 0.92f, 0.92f ,1f);
                    this.ResultsTable.Delegate = _tableViewDelegateShim;
                    this.ResultsTable.DataSource = _tableViewDataSource;
                    this.ResultsTable.Hidden = true;
                    this.AddSubview(this.ResultsTable);

                    _popoverController = null;
                }

                this.BringSubviewToFront(this.Separator);
            }

            this.BringSubviewToFront(this.TokenField);

            this.UpdateContentSize();

            _hasSetup = true;// init workaround
            this.Frame = this.Frame;// init workaround
        }
예제 #3
0
        protected virtual void Setup()
        {
            _tokenDelegateShim     = new TITokenFieldDelegateShim(this);
            _tableViewDelegateShim = new TableViewDelegateShim(this);
            _tableViewDataSource   = new TableViewDataSourceShim(this);

            this.BackgroundColor      = UIColor.Clear;
            this.DelaysContentTouches = true;
            this.MultipleTouchEnabled = false;

            this.TokenField = new TITokenField()
            {
                Frame = new RectangleF(0, 0, this.Bounds.Size.Width, 42)
            };

            this.ShowAlreadyTokenized  = false;
            this.SearchSubtitles       = true;
            this.ForcePickSearchResult = false;
            this.ResultsArray          = new List <object>();


            this.TokenField.Started        += tokenField_DidBeginEditing;
            this.TokenField.Ended          += tokenField_DidEndEditing;
            this.TokenField.EditingChanged += tokenField_TextDidChange;

            this.TokenField.FrameWillChange += tokenField_FrameWillChange;
            this.TokenField.FrameDidChange  += tokenField_FrameDidChange;

            this.TokenField.Delegate = _tokenDelegateShim;

            this.AddSubview(this.TokenField);

            float tokenFieldBottom = this.TokenField.Frame.Bottom;

            this.Separator = new UIView(new RectangleF(0, tokenFieldBottom, this.Bounds.Size.Width, 1));
            this.Separator.BackgroundColor = UIColor.FromWhiteAlpha(0.7f, 1f);
            this.AddSubview(this.Separator);

            // This view is created for convenience, because it resizes and moves with the rest of the subviews.
            this.ContentView = new UIView(new RectangleF(0, tokenFieldBottom + 1, this.Bounds.Size.Width, this.Bounds.Size.Height - tokenFieldBottom - 1));
            this.ContentView.BackgroundColor = UIColor.Clear;
            this.AddSubview(this.ContentView);

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                UITableViewController tableViewController = new UITableViewController(UITableViewStyle.Plain);
                tableViewController.TableView.Delegate   = _tableViewDelegateShim;
                tableViewController.TableView.DataSource = _tableViewDataSource;
                tableViewController.PreferredContentSize = new SizeF(400, 400);

                this.ResultsTable = tableViewController.TableView;

                _popoverController = new UIPopoverController(tableViewController);
            }
            else
            {
                this.ResultsTable = new UITableView(new RectangleF(0, tokenFieldBottom + 1, this.Bounds.Size.Width, 10));
                this.ResultsTable.SeparatorColor  = UIColor.FromWhiteAlpha(0.85f, 1f);
                this.ResultsTable.BackgroundColor = UIColor.FromRGBA(0.92f, 0.92f, 0.92f, 1f);
                this.ResultsTable.Delegate        = _tableViewDelegateShim;
                this.ResultsTable.DataSource      = _tableViewDataSource;
                this.ResultsTable.Hidden          = true;
                this.AddSubview(this.ResultsTable);

                _popoverController = null;
            }

            this.BringSubviewToFront(this.Separator);
            this.BringSubviewToFront(this.TokenField);

            this.UpdateContentSize();

            _hasSetup  = true;       // init workaround
            this.Frame = this.Frame; // init workaround
        }