- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在 NavigationController 中嵌入了一个 TableView(并且嵌入在 TabBar Controller 中)。我在每个单元格中都有一个用户名按钮,可以连接到用户的个人资料。
然而,当我在个人资料页面的导航栏上点击“返回”并返回到 tableview 后,似乎我遇到了一些问题。
如果我再次下拉,它会刷新,但这次,顶行的用户名变得不可点击,而其他行按预期工作。
请注意,我在 tableView 的 viewDidLoad
中调用了 self.theRefreshControl = UIRefreshControl()
,但我不确定在使用后它是否被调用返回键。
请注意,我使用 prepareForSegue
执行 segue。
总结
如果我转到通知页面并尝试单击用户名,单击用户名按钮并继续运行
如果我转到通知并拉动刷新,第一行的用户名按钮不起作用
如果我转到通知但不进行任何刷新,用户名按钮会继续并返回(因此不会出现错误)。
如果我转到通知并拉动刷新,refreshControl 图标出现并消失,但现在,它不允许我点击顶行的用户名按钮。
如果我刷新通知,它不会让我点击第一行的用户名。如果我点击第二个单元格中的第二个用户名,它会转到用户的个人资料,但是当我点击后退按钮时,它会出现如下错误:
ViewDidLoad() 中的代码:
override func viewDidLoad() {
super.viewDidLoad()
self.theRefreshControl = UIRefreshControl()
self.theRefreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
self.theRefreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
self.tableView.addSubview(theRefreshControl)
}
func refresh(sender: AnyObject) {
if isFirstLoad == false {
currentPage = 1
getStuff()
}
self.theRefreshControl.endRefreshing()
}
我还尝试在 self.tableView.addSubview(theRefreshControl)
上方和下方添加 self.tableView.backgroundView = refreshControl
;还尝试用 self.tableView.backgroundView = refreshControl
替换 self.tableView.addSubview(theRefreshControl)
但不幸的是没有运气
最佳答案
你应该像这样实例化 refreshControl 的方式:
override func viewDidLoad() {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: "refresh:", forControlEvents: .ValueChanged)
tableView.backgroundView = refreshControl // <- THIS!!!
}
如 this answer 中所述.
我猜你的 refreshControl 在你的单元格前面,所以如果上面的方法不起作用试试这个: viewDidLoad
中的 tableView.sendSubviewToBack(theRefreshControl)
/p>
编辑:由于 tableView.sendSubviewToBack(theRefreshControl)
是解决方案,请考虑向 Apple 提交错误,因为它应该在您设置 refreshControl 时自动发生
作为 tableView.backgroundView
关于ios - 在 NavBar 上使用 Back 后,RefreshControl 会导致 TableView 的第一个 Cell 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35391236/
我正在使用 RefreshControl列表中的组件在半透明的 app-header-bar 下方滚动。 我唯一的问题是 RefreshControl 出现在半透明标题下方。我真正想要的是能够偏移 R
我为我的 tableview 实现了一个 refreshcontrol,它工作正常。但我想实现调用另一个类在该类中执行进程。我希望我的 refreshcontrol 应该等到那个类的执行。 例如:我在
我正在尝试将refreshControl连接到Rest api,以便每次刷新时都会更新内容。然而,即使它有效,当您释放刷新控件时,它似乎会导致非常滞后且不流畅的体验。这是为什么? 刷新时调用的方法 f
刷新进度完成后,我的刷新控件不会消失。它保持动画,即使我调用了 endRefreshing()。 import UIKit class MyTableViewController: UITableVi
我有一个带有 refreshControl 属性的 ScrollView 的屏幕。结果是,当我刷新屏幕时,屏幕的全部内容都向下移动了几个位置。如果我再次刷新,它会继续下降,依此类推。 此屏幕截图是在刷
应用程序选项卡使用刷新按钮来更新列表,效果很好。尝试使用“下拉刷新”,但根本不起作用。 protocol StaffHistoryDelegate: class { func updateLi
我有一个带有刷新控件的 UITableViewController。当你向下拉时,它工作正常——微调器旋转,标题显示,一切正常。但是,当我使用以下代码以编程方式触发控件时,属性标题不会显示: -(vo
我有这条线 self.refreshControl = [[UIRefreshControl alloc] init]; 但它不被识别,我得到一个编译错误: property refreshContr
我有一个管理大量单元格的 UICollectionView。当我删除一个单元格时,我希望该单元格随 refreshControl 一起消失。但我不明白为什么 reloadData 不起作用。如果有人可
我正在使用 RefreshControl 在按下按钮后启动刷新屏幕,代码如下。但是,即使设置了刷新变量的状态,刷新也不会开始。 const [refresh, setRefresh] = useSta
我有一个 TableView,我在其中从 api 获取数据。在获取/显示数据和分页/无限滚动方面一切正常。但是,当我尝试使用我的 RefreshControl 时,它崩溃并出现错误: Array in
在搜索过程中,我想禁用下拉刷新机制。所以我禁用了刷新控件并将其删除。但是当下拉刷新时会调用 beginRefresh 方法,单元格会保持下拉状态 2 秒,就像刷新一样。 func searchBarS
我正在使用这个 tutorial使用 RefreshControl 实现下拉刷新行为。我正在使用 导航栏。使用普通标题时一切正常。但是,当使用“首选大标题”时,它无法正常工作,如您在以下视频中所见。任
我有一个 FlatList使用标准 RefreshControl ,像这样: } renderItem={({ item, index }) => ()} /> 这会在执行下拉刷新操作时呈现
编辑:React Native 似乎有一个错误。我在 GitHub 上创建了一个错误。求解答的各位:目前好像没有。 https://github.com/facebook/react-native/i
我使用 tableview 开发应用程序,用户可以在其中拉动以刷新。 当我下拉表格时,标题和刷新控件之间有额外的空间。 我这样设置 UIRefreshcontrol 和标题背景 viewDidLoad
我写了一个扩展,允许我在 UIViewController 中的常规 tableView 上显示 refreshControl。下面的代码在 viewDidLoad() 和拉动刷新时完美运行。 扩展名
我的 View 中有一个可滚动的内容。我想在其中添加拉动刷新。我尝试添加但未触发操作。 我尝试了很多方法并重新搜索,但没有一种对我有用。我将 iOS 10 作为最低部署目标。 尝试1: let ref
我使用 Firebase 作为我的数据结构。我在 UITableView 的 refreshControl 中使用完成处理程序,以便在从 Firebase 加载完所有数据后停止刷新。 override
从 react-native@0.26 升级后,RefreshControl 的事件指示器有时会出现在 iOS 上的 ScrollView 的右上角。我按照文档所述正确使用 RefreshContro
我是一名优秀的程序员,十分优秀!