3

映画のクレジットが表示されるときのように、スクロール ビュー (または textView) を自動的にスクロールする必要があります。いくつかの方法を試しましたが、どれもうまくいかず、十分な答えが見つからないようです。どんな助けでも大歓迎です!!

前もって感謝します!

4

3 に答える 3

4

このコードはUIScrollView、10 秒で 100ptをスクロールします。

self.scrollView.scrollEnabled = NO;

CGFloat scrollHeight = 100;
[UIView animateWithDuration:10
                      delay:0
                    options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
                 animations:^{
                     self.scrollView.contentOffset = CGPointMake(0, scrollHeight);
                 }
                 completion:nil];
于 2012-09-25T13:52:04.850 に答える
1

これを試して。

[your table-name scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:pageval inSection:0] atScrollPosition:0 animated:YES];

行番号を渡して、indexPathForRow行の終わりまでインクリメントすることができます。

それがうまくいくと思います。

これが役立つことを願っています

**

テキストビューを使用しているので、これを試すことができます

**

count=txtvw.frame.size.height; //integer counter initialized as textview's height

//call "scrolltextview" method at regular time interval. (here it is calling method in 0.3 second timespan)
self.timer = [NSTimer scheduledTimerWithTimeInterval:.3f
                                                  target:self
                                                selector:@selector(scrolltextview)
                                                userInfo:nil
                                                 repeats:YES];



 -(void)scrolltextview
{


     //iterate "count" every time the method is called by the lineheight of textview's font.
        count=count+ txtvw.font.lineHeight;


    if(count<=txtvw.text.length)
    {
    NSRange range = NSMakeRange(count - 1, 1);

        [txtvw scrollRangeToVisible:range]; // scroll with range
    }
    else {
        [timer invalidate]; // if count match with the condition than invalidate the timer so method not called now.
    }

}



これをNSTimerオブジェクトで使用します。これが役立つことを願っています。

于 2012-09-20T03:57:39.700 に答える