SWIFT UITableview根据内容设置autoheight – XCode – iOS

SWIFT UITableview根据内容设置autoheight – XCode – iOS,第1张

概述根据内容动态自动调整UITableView的高度. 我尝试了以下解决方案,但对我不起作用: dispatch_async(dispatch_get_main_queue()) { //This code will run in the main thread: CGRect frame = self.tableView.frame; frame.si 根据内容动态自动调整UItableVIEw的高度.
我尝试了以下解决方案,但对我不起作用:

dispatch_async(dispatch_get_main_queue()) {        //This code will run in the main thread:        CGRect frame = self.tableVIEw.frame;        frame.size.height = self.tableVIEw.contentSize.height;        self.tableVIEw.frame = frame;    }

SOURCE

解决方法 我遇到了同样的问题.我通过简单地将UItableVIEw内容高度传递给UITabelVIEw框架高度来解决它.

func UItableVIEw_auto_Height()    {        if(self.UItableVIEw.contentSize.height < self.UItableVIEw.frame.height){            var frame: CGRect = self.UItableVIEw.frame;            frame.size.height = self.UItableVIEw.contentSize.height;            self.UItableVIEw.frame = frame;        }    }

在vIEwController的vIEwDIDAppear函数中调用上面的函数.

overrIDe func vIEwDIDAppear(animated: Bool) {        UItableVIEw_auto_Height();    }
总结

以上是内存溢出为你收集整理的SWIFT UITableview根据内容设置autoheight – XCode – iOS全部内容,希望文章能够帮你解决SWIFT UITableview根据内容设置autoheight – XCode – iOS所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1001735.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存