MvvmCross Hamburger menu for iOS

我的未来我决定 提交于 2019-12-24 02:33:39

问题


I'm using https://www.marcbruins.nl/xamarin-ios-hamburger-menu-mvvmcross/ and it works on Portrait orientation:

But on Landscape orientation I have not fill width:

Menu class:

[MvxPanelPresentation (MvxPanelEnum.Left, MvxPanelHintType.ResetRoot, false)]
    public partial class MenuView : MvxViewController<MenuViewModel>
    {
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();                        

            EdgesForExtendedLayout = UIRectEdge.Right;                  

            MenuTableView.Source = new MenuTableViewSource(ViewModel.MenuItems);                

            var separator = new UIView(new CGRect(0, 0, this.View.Frame.Size.Width, 0.8));
            separator.BackgroundColor = UIColor.FromRGB(210, 210, 210);
            MenuTableView.TableHeaderView = separator;
        }
    }

Table Source:

public class MenuTableViewSource : UITableViewSource
    {
        List<MenuModel> TableItems;
        string CellIdentifier = "MenuTableViewCell";

        public MenuTableViewSource (List<MenuModel> menuItems)
        {
            TableItems = menuItems;
        }

        public override nint RowsInSection (UITableView tableview, nint section)
        {
            return TableItems.Count;
        }

        public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
        {
            MenuTableViewCell cell = tableView.DequeueReusableCell (CellIdentifier) as MenuTableViewCell;
            MenuModel item = TableItems[indexPath.Row];

            if (cell == null)
                cell = MenuTableViewCell.Create ();

            cell.BackgroundColor = UIColor.White;

            cell.SeparatorInset = UIEdgeInsets.Zero;
            cell.LayoutMargins = UIEdgeInsets.Zero;
            cell.MenuItemTextLabel.Text = item.Title;
            cell.AccessoryView = new UIImageView(image: new UIImage("chevron-right.png"));

            return cell;
        }

        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            MenuModel item = TableItems[indexPath.Row];
            item.Navigate.Execute(null);
            Mvx.Resolve<IMvxSideMenu>().Close();
        }

        public override nfloat GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
        {
            return 60f;
        }
    }

Also I tried to increase width of View - not working.

Bug on iPad.

Advice, please how to fix it.

来源:https://stackoverflow.com/questions/46224467/mvvmcross-hamburger-menu-for-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!