Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Let the code runs in main thread when a cell is selected in demo code. #3

Closed
leizh007 opened this issue Jan 12, 2016 · 11 comments
Closed

Comments

@leizh007
Copy link

In Demo MainViewController.swift, the code should be wrapped in dispatch_async(dispatch_get_main_queue()) {...} , otherwise it will delay some seconds when response the user tapped event. I don't know why, but run in main thread can solve the delay problem. Something like that:

// MARK: - Table view delegate

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        guard let cell = tableView.cellForRowAtIndexPath(indexPath) else { return }
        dispatch_async(dispatch_get_main_queue()) { () -> Void in
            //custome code here
        }
    }

`

@leizh007
Copy link
Author

Twitter的动画效果在dismiss的最后阶段不平滑,界面会跳一下。

@DianQK
Copy link
Owner

DianQK commented Jan 12, 2016

About Twitter , You can try set navigationController?.navigationBarHidden = false, then everything will be well. I am not sure what happened(maybe due to AutoLayout?)

Twitter 的这个效果中,会出现移位的情况,我也很好奇为什么会这样,你可以试试设置navigationController?.navigationBarHidden = false,这样的时候效果就会没问题了,可能是由于状态栏或者 AutoLayout

@DianQK
Copy link
Owner

DianQK commented Jan 12, 2016

延迟这个我也很奇怪Amazing我的运行环境是 iOS 9.2 ,你可以试试看新建一个 tableview 的项目,运行一下,是否响应也是延迟的?

@leizh007
Copy link
Author

延迟的问题我也不太知道为什么,有的时候确实会出现这个问题,之前去stackoverflow上搜,别人给出的方法是把代码gcd包一下放到主线程里就没有延迟了。

@DianQK
Copy link
Owner

DianQK commented Jan 12, 2016

你的环境是 iOS 8 吗?我记得在 8 的时候,会有这样的情况发生。

@leizh007
Copy link
Author

iOS9.2,我在模拟器里运行的,也可能是我的个例?

@DianQK
Copy link
Owner

DianQK commented Jan 12, 2016

Maybe~如果在手机上呢?

@leizh007
Copy link
Author

在真机上刚测过,5c,系统9.2,跟模拟器上一样的问题,就只点那个twitter,有时候点一下没反应,点第二下才会有反应。但是把代码放倒main thread里,在模拟器和手机上都是任何时候点一下就会有反应,不知道什么原因。。。

@DianQK
Copy link
Owner

DianQK commented Jan 12, 2016

Get. 晚一些会尝试解决这个问题.

@DianQK
Copy link
Owner

DianQK commented Jan 12, 2016

Fixed~ 感谢提醒 ^^

@DianQK DianQK reopened this Jan 17, 2016
@DianQK
Copy link
Owner

DianQK commented Jan 17, 2016

HiHi已经解决了 Twitter 的问题,Autolayout: Add constraint to superview and not Top Layout Guide?,我们应该添加约束到View上,而不是Top Layout Guide。目前最新的是 2.0.0 版本

@DianQK DianQK closed this as completed Jan 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants