第一个ScrollView滚动时滚动第二个Scrollview

时间:2017-06-28 11:02:52

标签: ios swift function swift3 uiscrollview

我的项目中有两个void m1(Integer arg) { long i = arg; } ,他们应该同时滚动。滚动'use strict'; var gulp = require('gulp'); var rename = require('gulp-rename'); var uglify = require('gulp-uglify'); var watch = require('gulp-watch'); let cleanCSS = require('gulp-clean-css'); var rev = require('gulp-rev'); var jsArr = [ 'search/media/src/js/*.js', //'common/media/js/*.js', '!search/media/src/js/*.testmin.js', '!search/media/src/js/*.min.js' // '!common/media/js/*.testmin.js', ]; var cssArr = [ 'search/media/css/*.css', '!search/media/css/*.testmin.css', '!search/media/css/*.min.css' ]; gulp.task('js', function () { //return gulp.src(jsArr, {base: './'}) return gulp.src(jsArr) .pipe(watch(jsArr)) .pipe(uglify()) .pipe(rename({suffix: '.testmin'})) .pipe(rev()) .pipe(gulp.dest(function (file) { return file.base; })) .pipe(rev.manifest({ merge: true })) .pipe(gulp.dest('./')); }); gulp.task('css', function () { //return gulp.src(cssArr, {base: './'}) return gulp.src(cssArr) .pipe(watch(cssArr)) .pipe(cleanCSS()) .pipe(rename({suffix: '.testmin'})) .pipe(rev()) .pipe(gulp.dest(function (file) { return file.base; })) .pipe(rev.manifest({ merge: true })) .pipe(gulp.dest('./')); }); gulp.task('default', ['js', 'css'], function () { }); var watcher = gulp.watch([jsArr, cssArr], ['default']); watcher.on('change', function (event) { console.log('File ' + event.path + ' was ' + event.type + ', running tasks...'); }); 时它应该有效。

这是我未完成的代码:

ScrollViews

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

您可以使用其委托方法。 并在其他ScrollView上设置OffSet内容

  func scrollViewDidScroll(_ scrollView: UIScrollView!) {
            // This will be called every time the user scrolls the scroll view 

       if  myFriendsScrollView ==scrollView 
        {
           let contentOffSet = scrollView.contentOffset

         //change the Off set of other ScrollView   
     // just surround with main thread 

      DispatchQueue.main.async {
         secondScrollView.setContentOffset=contentOffSet;
       }
    }



  }

我希望这会对你有所帮助

答案 1 :(得分:1)

看起来你的委托方法的实现已经是正确的,我已经在游乐场测试了它似乎工作得很好。

然而,它看起来并没有真正吸引人。确保你的班级是:

class profileController: UIViewController, UIScrollViewDelegate { ... }

并添加viewDidLoad

myFriendsScrollView.delegate = self
myFriendsNameScrollView.delegate = self