- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要将表格滚动到底部。当我在 viewwilAppear 中编写滚动表格的代码时,它不起作用,但是当我在 viewDidAppear 中编写相同的代码时,它可以工作,但用户会看到滚动。我不想看到用户滚动如何在 ViewWillAppear 中使 tableScrolling。`
override func viewWillAppear(animated: Bool)
{
super.viewWillAppear(animated)
UIApplication.sharedApplication().delegate!.window!!.windowLevel = UIWindowLevelNormal
self.view.backgroundColor = UIColor.whiteColor()
viewWillAppearExecuted = true
executeCodeOfViewViewAppear()
}
func executeCodeOfViewViewAppear() {
if viewWillAppearExecuted {
viewWillAppearExecuted = false
if appNeedsAutoResize{
self.noLongerParticipantMessageLabel.font = UIUtils.getFontForApproprieteField(.Footnote).font
self.typingStatusLabel.font = UIUtils.getFontForApproprieteField(.Headline).font
}
withAnimationFlag = true
if !self.composeBar.textView.isFirstResponder()
{
// This block will execute if compose bar is first responder
self.updateTableBottomCnt(value:self.composeBar.frame.size.height)
// Update compose bar constarint
if self.composeBarBottomConstraing.constant != 0
{
self.composeBarBottomConstraing.constant = 0
}
}
self.isOpenNextScreen = false
self.checkIfloginUserisActiveMember()
self.tabBarController?.tabBar.hidden = true
ChatCommonCall.sharedInstance.currentThreadIdForPush = self.threadInfo.threadId
// This block is used for make a responder to keyboard for send message.
if shouldComposeBarFirstResponder == true {
self.composeBar.becomeFirstResponder()
shouldComposeBarFirstResponder = false
}
self.showMessageById(self.messageIdForMessageDisplay)
ChatCommonCall.sharedInstance.isChatModuleScreen = true
self.changeFrame()
self.composeBar.button.enabled = self.composeBar.text.trim().length > 0 ? true : false
/// Table frame changes.
switch self.optType
{
case .NewMessageSection:
break
case .DoNotHandle :
break
case .None :
if !(self.messageIdForMessageDisplay.isEqual(Guid.emptyGuid()))
{
self.optType = .ShowMessageOfID(id: self.messageIdForMessageDisplay)
}
else {
self.optType = .ScrollToBottom
}
break
default :
break
}
switch self.optType
{
case .NewMessageSection :
break
default :
self.handleOptType()
}
//Implemented the new observer pattern in the whole project where we suppose to refresh the screen for background sync data
//By Nikhil Kumar Saraf on 19 July 2016
Notifier.Unregister()
let observer = DatabaseObserverInfo(tName: ["chatthread","chatthreadmember","chatmessage","chatmessagereceiver","chatthumbnail","pfthumbnail","chatmessagemarker"], oType: [SyncOpType.Insert,SyncOpType.Update,SyncOpType.Delete], observer: self, stick: false, syncTrigger: SyncTriggerType.Post)
Notifier.Register(observer)
//By Balkrishan Yadav for AutoResizing UI on 30 Nov. 2016
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ChatMessageController.didChangePreferredContentSize(_:)), name:UIContentSizeCategoryDidChangeNotification, object: nil)
// This condition will execute if some one sharing image and coming to the chat message screen
//@Balkrishan Yadav
if ChatCommonCall.sharedInstance.attachmentInfo != nil {
self.addFileInComposeBar(ChatCommonCall.sharedInstance.attachmentInfo!)
ChatCommonCall.sharedInstance.attachmentInfo = nil
let dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(0.3 * Double(NSEC_PER_SEC)))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
// your function here
// self.changeController(true)
})
}
}
}
func handleOptType(callFromViewDidAppear:Bool = false) {
switch optType {
case .ScrollToBottom : // No new message is available. show last message. self.messageTableView.setContentOffset(CGPointMake(0,CGFloat.max), animated: !isCameFromThreadComposer)
break
default:
// do nothing
}
最佳答案
如果您不希望滚动有动画效果,则只需将 false
作为 animated
参数传递给滚动函数即可。例如:
tableView.scrollToRow(at: indexPath, at: .top, animated: false)
此函数会将 indexPath
的行滚动到表格 View 的顶部,而不使用任何动画。
关于swift - 使用快速自动布局滚动到 cellForRowAt Index 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42022978/
当我尝试运行代码时,cellForRowAtIndexPath 函数由于某种原因无法运行。 numberOfSections 函数运行良好。我认为这是 dataSource/delegate 函数或单
我对使用 cellForRowAt 执行代码的顺序有疑问 这是我的 cellForRowAt 函数 func tableView(_ tableView: UITableView, cellForRo
我需要检测 UITableViewController 中的按钮是否被点击 override func tableView(_ tableView: UITableView, cellForRowAt
我创建了两个类 NumberTableViewCell 和 YesNoTableViewCell,它们的类型均为 UITableViewCell。它们“附加”了动态原型(prototype)(如果我说
我的程序构建如下: 我有一个 UIViewController SingleEventViewController 来布局和处理事件的数据。它的元素之一是 UIView TeilnehmerTable
根据下面的代码,我第一次运行应用程序。前 3 行工作正常。但是当我上下滚动时。一些线路也会改变。当我做更多的上下它更改为其他行 我该如何解决这个问题 func tableView(_ tabl
我在 UITableViewController 中创建 TableView 时遇到问题。行数返回非零数,高度在 Storyboard 中设置。但是 cellForRowAt永远不会被调用。 这是代码
这个问题让我疯狂了 3 天。我创建了一个自定义单元类: class TransitoPalinaTableViewCell: UITableViewCell { @IBOutlet weak var
我认为我很接近,但似乎让自己感到困惑,因为我可以访问所有数据,但无法使其正常运行。 我正在尝试在表格 View 的表格中显示其各自公司(部门)下的员工列表。 我的 CoreData 在存储值和关系方面
你能帮我找到一个解决方案,而不是一次又一次地复制相同的代码吗?现在我有了这段代码 func tableView(_ tableView: UITableView, cellForRowAt i
我在使 cellForRowAt 工作时遇到问题,但不幸的是我的应用程序在编译后仍然是空白的。我正在使用 Xcode 8.3 beta 3。 import UIKit class myCell: UI
我是 swift 和 UITableView 的新手,我正在从请求中获取数据,并试图在表格 View 上显示结果。我得到的数据很好,但我的表格 View 不滚动。我知道这个问题有很多问题,但我看到其他
我试图在按下 UITabelViewCell 时获得不同的标签文本,但我无法让它工作。 completed 的默认值为 false,触摸时应为 true,然后应更改标签。在 didSelectRowA
这个问题在这里已经有了答案: How to get the indexpath.row when an element is activated? (20 个答案) 关闭 5 年前。 我想访问 ce
我有一个 ChatViewController 和聊天消息。我使用 Storyboard 约束和标识符初始化消息气泡的布局,以通过代码更改它们: func tableView(_ tableView:
我需要将表格滚动到底部。当我在 viewwilAppear 中编写滚动表格的代码时,它不起作用,但是当我在 viewDidAppear 中编写相同的代码时,它可以工作,但用户会看到滚动。我不想看到用户
我有一个问题,numberOfRowsInSection 和 cellForRowAt 函数不返回值。我需要将名称和价格从 coincap.io/front API 返回到 tableView 中。我
我正在尝试拥有 UITableView (主要)其中包含另一个 UITableView (次要)在每个单元格中。主要和次要 TableView 都有自己的数据源对象类,MajorDatasource
我是一名入门级 swift 开发人员,我正在个人应用程序中工作,但我的“tableViewController”遇到了问题。 我有一个第一个表格 View ,我从 API 中获取一些事件,然后我想做的
我有一个显示购物 list 名称的 TableView Controller 。这些购物 list 是通过购物 list 类创建的,它让我可以指定购物 list 的名称和其中的项目。此 TableVi
我是一名优秀的程序员,十分优秀!