无法让UITableView在我的SlidingPanel内滚动

时间:2014-01-17 23:13:09

标签: ios xamarin.ios xamarin mvvmcross

我在一个附加到SlidingPanel的视图中有一个UITableView。

我正在使用SlidingPanels.Lib,我有一个自定义演示者

Here's a gist of the custom presenter

从那里我的MenuView非常直接。

public class MenuView : ViewControllerBase
{
    private new MenuViewModel ViewModel { get { return (MenuViewModel)base.ViewModel; } }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        // todo: this should actually be...
        // _currentBookId = currentUser.UserBooks[0].BookId;
        // _homeViewModel.ChapterViewModel = Mvx.Resolve<IChapterService>().FindByBookId(_currentBookId);
        ViewModel.Chapters = Mvx.Resolve<IChapterService>().Find();

        // this ensures the sliding panel doesn't fill the entire view.
        var frame = View.Frame;
        frame.Width = 300;
        View.Frame = frame;

        // var currentUser = Mvx.Resolve<IUserService>().GetById(Mvx.Resolve<UserModel>().Id);

        var label = new UILabel(new RectangleF(10, 10, 300, 40))
        {
            TextColor = UIColor.White,

        };
        Add(label);

        //var listHeight = (chapters.Count*40);
        var navigationList = new UITableView(new RectangleF(0, 50, 300, 300))
            {
                Source = new NavigationTableSource(ViewModel.Chapters)
            };
        Add(navigationList);

        var set = this.CreateBindingSet<MenuView, MenuViewModel>();
        set.Bind(label).To(vm => vm.DisplayName);
        set.Apply();
    }
}

不幸的是,我不确定在哪里查看以允许TableView滚动。我可以看到它,但它超出了屏幕的底部。

2 个答案:

答案 0 :(得分:0)

我认为问题在于:

        var listHeight = (chapters.Count*40);

请尝试将高度设置为可用屏幕的高度(取决于您所使用的iPhone / iPad),而不是这样。在此之后,列表将在可用高度内滚动。

答案 1 :(得分:0)

花了几个小时的时间来发现我从@ patbonecrusher的Github repo抓取的原始源代码与你在@ fcaico的Github repo

长话短说......我所要做的就是编译@ fcaico的版本并将其部署到我的应用程序中,滚动回来了。现在我意识到@fcaico的repo只包含一个@patbonecrusher的子模块,但由于某种原因......重新编译修复了这个问题。没有太多时间深入研究原因。