Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewController带有额外空间的滚动(如Notes应用程序)_Ios_Objective C_Uitableview_User Interface_Scroll - Fatal编程技术网

Ios UITableViewController带有额外空间的滚动(如Notes应用程序)

Ios UITableViewController带有额外空间的滚动(如Notes应用程序),ios,objective-c,uitableview,user-interface,scroll,Ios,Objective C,Uitableview,User Interface,Scroll,如何复制Notes应用程序中的此行为: 您有一个带有项目的UITableViewController 您可以向下滚动列表(包含许多项) 当你点击列表底部时,你可以稍微“过度滚动”,但列表不会一直向后滚动。最后一项下还有一些空间。此空间在注释中用于显示某些布局图像 要用照片演示: 这是一个“未滚动”列表。使用UITableViewController创建这样的控件很容易。当您向上“拉”列表时,默认的UITableViewController会返回到此状态 但是,Notes允许这样做: 在滚动以

如何复制Notes应用程序中的此行为:

  • 您有一个带有项目的
    UITableViewController
  • 您可以向下滚动列表(包含许多项)
  • 当你点击列表底部时,你可以稍微“过度滚动”,但列表不会一直向后滚动。最后一项下还有一些空间。此空间在注释中用于显示某些布局图像
  • 要用照片演示:

    这是一个“未滚动”列表。使用
    UITableViewController
    创建这样的控件很容易。当您向上“拉”列表时,默认的
    UITableViewController
    会返回到此状态

    但是,Notes允许这样做:

    在滚动以留出一点空间后,不要让它一直弹回


    如何复制这种行为?

    您可以像这样更改tableView的内容插入:

    [_tableView setContentInset:UIEdgeInsetsMake(0, 0, 100, 0)];
    

    在这里,滚动时,您将在tableView的底部插入100像素的内容。

    这里有一个简单的方法

    只需(在ViewDidLoad中)将一个空白UIView作为表尾添加到UITableView

    大概是这样的:

    UIView *footer = [[UIView alloc] init];
    footer.frame = CGRectMake(0, 0, 0, 100); // The only one that matters here is the height
    self.tableView.tableFooterView = footer; // tableView is an outlet to the tableView
    
    斯威夫特:


    Swift:

    我认为在Swift中这样做的方式是这样的

    tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0)
    

    我知道这是一个老生常谈的问题,但它可能会让某些人受益。

    更新Kirualex回复:

    理想位置:UITableViewController viewDidLoad

    Swift 3:
    tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0)
    
    // Add 50 extra pixels at bottom of the list when scrolling
    self.tableView.contentInset = UIEdgeInsets(top:0, left: 0, bottom: 50, right: 0)