{"id":597,"date":"2023-02-25T20:02:51","date_gmt":"2023-02-25T12:02:51","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=597"},"modified":"2023-02-26T08:15:33","modified_gmt":"2023-02-26T00:15:33","slug":"swift-ui-move-uitableview-scroll-bar-to-bottom","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/swift-ui-move-uitableview-scroll-bar-to-bottom\/","title":{"rendered":"Swift UI &#8211; \u5c06\u8868\u683cUITableView\u6eda\u52a8\u6761\u79fb\u52a8\u5230\u5e95\u90e8"},"content":{"rendered":"<blockquote>\n<p>\u6ce8\uff1a\u4ee3\u7801\u5df2\u5347\u7ea7\u81f3Swift4<\/p>\n<\/blockquote>\n<p>\u6709\u65f6\u6211\u4eec\u9700\u8981\u901a\u8fc7\u4ee3\u7801\u81ea\u52a8\u5c06\u8868\u683c UITableView \u6eda\u52a8\u6761\u79fb\u52a8\u5230\u5c3e\u90e8\uff0c\u4e0b\u9762\u5206\u522b\u4ecb\u7ecd\u4e24\u79cd\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n<h3>\u4f7f\u7528scrollToRow\u65b9\u6cd5\u6eda\u52a8\u5230\u6700\u540e\u4e00\u884c<\/h3>\n<p><!-- more --><\/p>\n<pre><code class=\"language-swift\">let secon = 1 \/\/\u6700\u540e\u4e00\u4e2a\u5206\u7ec4\u7684\u7d22\u5f15\uff080\u5f00\u59cb\uff0c\u5982\u679c\u6ca1\u6709\u5206\u7ec4\u5219\u4e3a0\uff09\nlet rows = 10 \/\/\u6700\u540e\u4e00\u4e2a\u5206\u7ec4\u6700\u540e\u4e00\u6761\u9879\u76ee\u7684\u7d22\u5f15\nlet indexPath = IndexPath(row: rows, section: secon)\nself.tableView?.scrollToRow(at: indexPath, at:.bottom, animated: true)<\/code><\/pre>\n<h3>\u4f7f\u7528setContentOffset\u8bbe\u7f6e\u504f\u79fb\u91cf\u5b9e\u73b0\u6eda\u52a8<\/h3>\n<pre><code class=\"language-swift\">let offset = CGPoint(x:0, y:self.tableView!.contentSize.height\n                                - self.tableView!.bounds.size.height)\nself.tableView!.setContentOffset(offset, animated: true)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6ce8\uff1a\u4ee3\u7801\u5df2\u5347\u7ea7\u81f3Swift4 \u6709\u65f6\u6211\u4eec\u9700\u8981\u901a\u8fc7\u4ee3\u7801\u81ea\u52a8\u5c06\u8868\u683c UITableView \u6eda\u52a8\u6761\u79fb\u52a8\u5230\u5c3e\u90e8\uff0c\u4e0b\u9762\u5206 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[171],"tags":[],"class_list":["post-597","post","type-post","status-publish","format-standard","hentry","category-swift"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=597"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/597\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}