加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift3 – Swift 3 scrollToRowAtIndexPath成为scrollToRow

发布时间:2020-12-14 05:38:51 所属栏目:百科 来源:网络整理
导读:我正在转换一个 Swift 2.3项目o Swift 3并挖掘数千个变化 我目前有这样的代码: outletCatalog.scrollToRowAtIndexPath(myIndex,atScrollPoisition: .top,animated: false) 但是,它显然被替换为 func scrollToRow(at: IndexPath,at: UITableViewScrollPositi
我正在转换一个 Swift 2.3项目o Swift 3并挖掘数千个变化

我目前有这样的代码:

outletCatalog.scrollToRowAtIndexPath(myIndex,atScrollPoisition: .top,animated: false)

但是,它显然被替换为

func scrollToRow(at: IndexPath,at: UITableViewScrollPosition,animated: Bool)

但是 – 我不明白“at”的双参数命名,我的Google搜索没有产生任何结果.代码翻译工具只是表明了它

scrollToRow(at:at:animated)
在从Swift 2.3到Swift 3.2版本的代码转换之后,您需要在GCD主调度块内调用以下代码,并将自动滚动行的新更改调用到索引.
DispatchQueue.main.async {
   let index = IndexPath(row: 10,section: 0) // use your index number or Indexpath
   self.tableCart.scrollToRow(at: index,at: .middle,animated: true) //here .middle is the scroll position can change it as per your need
}

我希望它对你有用.

SupportSwift 3.1,3.2,4.1

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读