質問

いテーブルビューいと思うようになるとスクロールされた細胞は、"ポップ"で移動でテーブルを囲ます。のテーブルビューロギーンゲンアンデアブレンを長く押すと選択細胞がんができないスクロールの表示がん細胞を選択します。

本を読み漁り UIGestureRecognizerDelegate がんでいる。また、これらの方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

こちらは自分のコード:

- (IBAction)longPressGestureRecognized:(id)sender {

UILongPressGestureRecognizer *longPress = (UILongPressGestureRecognizer *)sender;
UIGestureRecognizerState state = longPress.state;
//longPress.delegate = self;

CGPoint location = [longPress locationInView:self.personTableView];
NSIndexPath *indexPath = [self.personTableView indexPathForRowAtPoint:location];

static UIView       *snapshot = nil;        ///< A snapshot of the row user is moving.
static NSIndexPath  *sourceIndexPath = nil; ///< Initial index path, where gesture begins.

switch (state) {
    case UIGestureRecognizerStateBegan: {
        if (indexPath) {
            sourceIndexPath = indexPath;

            UITableViewCell *cell = [self.personTableView cellForRowAtIndexPath:indexPath];
            // capture the color of the cell before blacking out
            savedTextColor = cell.detailTextLabel.textColor;

            // Take a snapshot of the selected row using helper method.
            snapshot = [self customSnapshotFromView:cell];

            // Add the snapshot as subview, centered at cell's center...
            __block CGPoint center = cell.center;
            snapshot.center = center;
            snapshot.alpha = 0.0;
            [self.personTableView addSubview:snapshot];
            [UIView animateWithDuration:0.25 animations:^{

                // Offset for gesture location.
                center.y = location.y;
                snapshot.center = center;
                snapshot.transform = CGAffineTransformMakeScale(1.05, 1.05);
                snapshot.alpha = 0.98;

                // Black out.
                cell.detailTextLabel.alpha = 0;
                cell.textLabel.alpha = 0;
            } completion:nil];
        }
        break;
    }
    case UIGestureRecognizerStateChanged: {
        CGPoint center = snapshot.center;
        center.y = location.y;
        snapshot.center = center;

        // Is destination valid and is it different from source?
        if (indexPath && ![indexPath isEqual:sourceIndexPath]) {

            // ... update data source.
            [dataSingelton saveUpdatedPersonList:(int)indexPath.row sourceIndex:(int)sourceIndexPath.row];
            //[[dataSingelton mutableDataArray] exchangeObjectAtIndex:indexPath.row withObjectAtIndex:sourceIndexPath.row];

            // ... move the rows.
            [self.personTableView moveRowAtIndexPath:sourceIndexPath toIndexPath:indexPath];

            // ... and update source so it is in sync with UI changes.
            sourceIndexPath = indexPath;
        }
        break;
    }

    default: {
        // Clean up.
        UITableViewCell *cell = [self.personTableView cellForRowAtIndexPath:sourceIndexPath];
        [UIView animateWithDuration:0.25 animations:^{
            snapshot.center = cell.center;
            snapshot.transform = CGAffineTransformIdentity;
            snapshot.alpha = 0.1;
            cell.detailTextLabel.alpha = 1;
            cell.textLabel.alpha = 1;
        } completion:^(BOOL finished) {
            [snapshot removeFromSuperview];
            snapshot = nil;
            cell.hidden = NO;
        }];
        sourceIndexPath = nil;
        break;
    }
}

}

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}



- (UIView *)customSnapshotFromView:(UIView *)inputView {

    UIView *snapshot = [inputView snapshotViewAfterScreenUpdates:YES];
    snapshot.alpha = 0.1;
    snapshot.layer.masksToBounds = NO;
    snapshot.layer.cornerRadius = 0.0;
    snapshot.layer.shadowOffset = CGSizeMake(-5.0, 0.0);
    snapshot.layer.shadowRadius = 5.0;
    snapshot.layer.shadowOpacity = 0.4;
    return snapshot;
}

私がセットに委譲する自己のようになります:

longPress.delegate = self;

のできるビューロだものの、その後の私の選択した細胞は動作しません。と思欠くこと。

*更新* 後のことにより、さまざまな研究だと思いるために私達成のために効果がんのスクロール効果のTableView ープンしたサンドイッチバー。天気アプリ)僕の長押しのジェスチャにも対応のスクロールのテーブル。デフォルトのスクロールをスクロール全体のテーブルを瞬時に、どさんありがとうございます。テーブルをスクロール時のみ、長押した細胞の表面または裏面のTableView.私正しいことを考えてこうなんだろう。っていう例があり、研究がなかったため運見もの。

**更新** うっそうとしていることをどのようにトリガーのスクロールタは、ユーザがユ細胞のプレーを生で体験してください。の問題なんてコーヒーに飽きたら寿司に出る細胞内シグナル伝達分子であり、その上のtableview,ヴ簡単に使ってみましたようなもの tableViewHight + 100, このコードポ作業時のtableviewでスクロールします。こちらはなんとい:

NSLog(@"This is table view hight %.2f", tableViewHight);

            NSLog(@"This is content offset %f",  (personTableView.contentOffset.y));

            NSLog(@"Should be 100 place holder %.2f", (tableViewHight - tableViewHight) + personTableView.contentOffset.y + 100);

            NSLog(@"location y %f", location.y);



            // gets called repeatedly
            // Step 1: check to see if we need to start scrolling
            if (location.y < tableViewHight - tableViewHight + 100) {
                // ** top **
                // Step 2: make sure the current y postoin isn't greater then the previous y postion
                if (location. y <= originalLocation.y) {
                   // NSLog(@"This is the offset y %f", self.personTableView.contentOffset.y);

                        // Step 4: check to see if we have a timer and if not create one
                        [self startTimer];


                }
                else{
                    //Step 3: they started to scroll up so end the timer
                    [self endTimer];
                }
            }
            else if(location.y > tableViewHight - 100)
            {
                // ** bottom **
                // Step 2: make sure the current y postoin isn't less then the previous y postion
                if (location. y >= originalLocation.y) {

                        NSLog(@"its less then 0");
                        if (!timer) {
                            // Step 4: check to see if we have a timer and if not create one
                            [self startTimer];
                        }


                }
                else{
                     //Step 3: they started to scroll up so end the timer
                    [self endTimer];
                }
            }
            else{
                // ** middle **
                // Step 2: check to see if we have a timer and if so destory it
                [self endTimer];
            }

基本的にはたいトリガをするif文の場合、細胞はその後から100pxの高さのスクロール可能なテーブル。

役に立ちましたか?

解決

から UILongPressGestureRecognizer を得ることができ現在の y の位置をタッチします。できることから計算方法の底部またはトップの UITableViewタッチです。まるで近いの始まりのスクロールを繰り返し NSTimer この単位または減算しcontentOffsetの UITableView 1ピクセルスクロールを表しています。サーボモーターの移動速で巻の変更 timeInterval のタイマー.

場合に UILongPressGestureRecognizer 終了、または y の位置をタッチするスクロールゾーンでは、それを無効にするタイマは、停止、スクロールします。

また冒険もあいまって、増加の速度スクロールのダイナミックなユーザに近づくの端 UITableView の変更 timeInterval として、ユーザーの動きをタッチを上下させるとともに、一般にどのようにこの機能です。

幸運を祈っています。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top