UIScrollView自动内容插入行为在iOS 11但不是iOS 10中工作?

时间:2017-12-20 23:21:23

标签: swift uiscrollview ios10 uiedgeinsets

我是游戏的新手,所以我真的只与UIScrollView合作,并且最近获得了胃灼热试图弄清楚苹果在他们现在被弃用的插入行为中的想法{ {1}}。 Apple的iOS 11插入调整行为的文档几乎完全针对func setView() { view = UIView() view.frame = UIScreen.main.bounds view.backgroundColor = UIColor.white } func addScrollView() { if #available(iOS 11.0, *) { scrollView.contentInsetAdjustmentBehavior = .always } scrollView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(scrollView) scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true scrollView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true scrollView.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true } func addFirstView() { firstView.translatesAutoresizingMaskIntoConstraints = false scrollView.addSubview(firstView) firstView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor).isActive = true firstView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true firstView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true firstView.heightAnchor.constraint(equalToConstant: 50).isActive = true } ... func addLastView() { lastView.translatesAutoresizingMaskIntoConstraints = false scrollView.addSubview(lastView) lastView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor).isActive = true lastView.topAnchor.constraint(equalTo: someOtherView.bottomAnchor).isActive = true lastView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true lastView.heightAnchor.constraint(equalToConstant: 100).isActive = true lastView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true }

程序化设置:

iOS 11

此设置在iOS 10中完美运行(内容插入会自动调整),但在automaticallyAdjustsScrollViewInsets中内容插入未调整 - 第一个视图与视图的顶部锚点齐平(不应该是状态栏的底部)。默认情况下,trueiOS 10。如何在<button data-url='api1.com' class='btn'>1</button> <button data-url='api2.com' class='btn'>2</button> $(".btn").click(function (e) { e.preventDefault(); $.ajax({ url: $(this).data('url'), async: false, success: function(result) { variable = result; } }); });

中启用自动内容插入调整行为

0 个答案:

没有答案