상속: UITableViewSource
        void SetUpTableView()
        {
            tableView = new UITableView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AllowsSelection = false,
                SeparatorStyle  = UITableViewCellSeparatorStyle.None,
            };
            tableView.RegisterClassForCellReuse(typeof(IncomingCell), IncomingCell.CellId);
            tableView.RegisterClassForCellReuse(typeof(OutgoingCell), OutgoingCell.CellId);
            View.AddSubview(tableView);

            var pinLeft = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f);

            View.AddConstraint(pinLeft);

            var pinRight = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f);

            View.AddConstraint(pinRight);

            var pinTop = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, TopLayoutGuide, NSLayoutAttribute.Bottom, 1f, 0f);

            View.AddConstraint(pinTop);

            var pinBottom = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1f, 0f);

            View.AddConstraint(pinBottom);

            chatSource       = new ChatSource(messages);
            tableView.Source = chatSource;
        }
예제 #2
0
        void SetUpTableView()
        {
            tableView = new UITableView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AllowsSelection = false,
                SeparatorStyle  = UITableViewCellSeparatorStyle.None
            };
            tableView.RegisterClassForCellReuse(typeof(IncomingCell), IncomingCell.CellId);
            tableView.RegisterClassForCellReuse(typeof(OutgoingCell), OutgoingCell.CellId);
            View.AddSubview(tableView);

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {   // iPhone X layout
                var safeGuide = View.SafeAreaLayoutGuide;
                tableView.TopAnchor.ConstraintEqualTo(safeGuide.TopAnchor).Active            = true;
                tableView.LeadingAnchor.ConstraintEqualTo(safeGuide.LeadingAnchor).Active    = true;
                tableView.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor).Active  = true;
                tableView.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -44).Active = true;
            }
            else
            {
                var pinLeft = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f);
                View.AddConstraint(pinLeft);

                var pinRight = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f);
                View.AddConstraint(pinRight);

                var pinTop = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, TopLayoutGuide, NSLayoutAttribute.Bottom, 1f, 0f);
                View.AddConstraint(pinTop);

                var pinBottom = NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1f, 0f);
                View.AddConstraint(pinBottom);
            }
            chatSource       = new ChatSource(messages);
            tableView.Source = chatSource;
        }
        void SetUpTableView()
        {
            tableView = new UITableView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AllowsSelection = false,
                SeparatorStyle = UITableViewCellSeparatorStyle.None,
            };
            tableView.RegisterClassForCellReuse (typeof(IncomingCell), IncomingCell.CellId);
            tableView.RegisterClassForCellReuse (typeof(OutgoingCell), OutgoingCell.CellId);
            View.AddSubview (tableView);

            var pinLeft = NSLayoutConstraint.Create (tableView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f);
            View.AddConstraint (pinLeft);

            var pinRight = NSLayoutConstraint.Create (tableView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f);
            View.AddConstraint (pinRight);

            var pinTop = NSLayoutConstraint.Create (tableView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, TopLayoutGuide, NSLayoutAttribute.Bottom, 1f, 0f);
            View.AddConstraint (pinTop);

            var pinBottom = NSLayoutConstraint.Create (tableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1f, 0f);
            View.AddConstraint (pinBottom);

            chatSource = new ChatSource (messages);
            tableView.Source = chatSource;
        }