如何在NavigationBar下使用iOS UITableView?

Dmi*_*riy 11 iphone objective-c uitableview xamarin.ios ios

我已经设定

NavigationController.NavigationBar.Translucent = true;
Run Code Online (Sandbox Code Playgroud)

然后添加表并将框架设置为RootView框架,并:

    public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            float y = this.TopLayoutGuide.Length;
            table.ContentInset = new UIEdgeInsets (y, 0, 0, 0);
        }
Run Code Online (Sandbox Code Playgroud)

但是,我在NavigationBar下有桌面滚动条(我使用monotouch):

在此输入图像描述

iPa*_*tel 30

刚刚放

navigationBar.translucent = NO; 你的问题会解决:)

其他选择是,,

下面的代码.

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if([self respondsToSelector:@selector(edgesForExtendedLayout)])
        [self setEdgesForExtendedLayout:UIRectEdgeBottom];
}
Run Code Online (Sandbox Code Playgroud)

另一种选择是......

为什么UIViewController在UINavigationBar下扩展,而UITableViewController却没有?


小智 8

试试这个:

    if([self respondsToSelector:@selector(edgesForExtendedLayout)])
    {
       self.edgesForExtendedLayout = UIRectEdgeNone;
       self.automaticallyAdjustsScrollViewInsets = NO;
    }
Run Code Online (Sandbox Code Playgroud)


Dmi*_*riy 5

我用这个简单的代码解决了任务:

table.ScrollIndicatorInsets = new UIEdgeInsets(64, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)

  • 对大小进行硬编码是一个坏主意。 (3认同)