objective-c - iOS 如何控制一秒内只能网络请求一次
PHP中文网
PHP中文网 2017-04-17 16:46:45
0
1
263

如题 在做一个实时搜索 发现有卡顿现象 应该是线程阻塞了 现在有什么办法能控制一秒内只能网络请求一次 求解答

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
黄舟

Directly block the monitoring response within 1 second
Without writing ObjC, the following is a solution to prevent rapid secondary clicks on Android.
The principle is probably the same, for reference.

private static long lastClickTime;
    public static boolean isFastDoubleClick() {
        long time = System.currentTimeMillis();
        long timeD = time - lastClickTime;
        if ( 0 < timeD && timeD < 1000) {
            return true;
        }
        lastClickTime = time;
        return false;
    }
 if (!isFastDoubleClick()) {
    //监听事件
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!