如何在iOS 11中向集合视图大标题导航栏添加刷新控件? [英] How to add refresh control to collection view large titles navigation bar in iOS 11?

查看:88
本文介绍了如何在iOS 11中向集合视图大标题导航栏添加刷新控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Apple的说法,刷新控件应该是iOS 11中大标题导航栏的一部分.

According to Apple the refresh control should be part of the large title navigation bar in iOS 11.

当我在情节提要中为UITableViewController启用刷新控件时,刷新控件是导航栏的一部分(拉动刷新时).

The refresh control is part of the navigation bar (on pull to refresh) when I enabled the refresh control in my storyboard for a UITableViewController.

我无法在情节提要中为所有其他视图(如UICollectionViewController)执行此操作.当我在代码中添加刷新控件作为子视图时,它不属于导航栏:

I can not do this in storyboard for all other views like UICollectionViewController. When I add a refresh control in code as a subview it is not part of the navigation bar:

refreshControl = UIRefreshControl()
collectionView?.addSubview(refreshControl)

虽然看起来像这样:

如何将刷新控件添加到UICollectionViewController之类的自定义滚动视图中,以便在使用大标题时在导航栏中显示刷新控件?

推荐答案

从iOS 10开始,UITableViewUICollectionView具有refreshControl属性.

As of iOS 10, UITableView and UICollectionView has refreshControl property.

所以,而不是:

tableView.addSubview(refreshControl)

您这样做:

tableView.refreshControl = refreshControl

这应该适用于iOS 11中的新大标题.

and this should work for new big headers in iOS 11.

这篇关于如何在iOS 11中向集合视图大标题导航栏添加刷新控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆