映画のクレジットが表示されるときのように、スクロール ビュー (または textView) を自動的にスクロールする必要があります。いくつかの方法を試しましたが、どれもうまくいかず、十分な答えが見つからないようです。どんな助けでも大歓迎です!!
前もって感謝します!
映画のクレジットが表示されるときのように、スクロール ビュー (または textView) を自動的にスクロールする必要があります。いくつかの方法を試しましたが、どれもうまくいかず、十分な答えが見つからないようです。どんな助けでも大歓迎です!!
前もって感謝します!
このコードは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];
これを試して。
[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
オブジェクトで使用します。これが役立つことを願っています。