UIScrollView-(バ=NO)のようにオーバーライド(pagingEnabled=YES)
-
22-07-2019 - |
質問
いUIScrollViewとページングの中でも代表的なモデルUIPageControl、ドラッグ/玉左右のページを、私の取り組みます。のかということがしたいと思っていく跳ね(できるような黒の背後にUI左右)、突然、ページングなくなります。
その場合:
scrollView.pagingEnabled = YES;
scrollView.bounces = YES;
全動作を除き、いバウンシングページ(0)およびページ(長さ1)です。がいこ
scrollView.pagingEnabled = YES;
scrollView.bounces = NO;
しかし、これらのようなすっぽんの場合、各ページの代わりに治療すべてのページにとって、長いページです。うのが理由でページングが依存性が大きく跳ね上がるというの跳ね.なしおりを付けることができなくすることはできるのでしょうか?たものがあるのか、それは何なのかになっているが悪いのでしょうか。
編集:その解決策
@interface PagingScrollView : UIScrollView
@end
@implementation PagingScrollView
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
self.pagingEnabled = YES;
self.bounces = YES;
}
return self;
}
- (void)setContentOffset:(CGPoint)offset
{
CGRect frame = [self frame];
CGSize contentSize = [self contentSize];
CGPoint contentOffset = [self contentOffset];
// Clamp the offset.
if (offset.x <= 0)
offset.x = 0;
else if (offset.x > contentSize.width - frame.size.width)
offset.x = contentSize.width - frame.size.width;
if (offset.y <= 0)
offset.y = 0;
else if (offset.y > contentSize.height - frame.size.height)
offset.y = contentSize.height - frame.size.height;
// Update only if necessary
if (offset.x != contentOffset.x || offset.y != contentOffset.y)
{
[super setContentOffset:offset];
}
}
@end
解決
最良のベットが書ける UIScrollView
サブクラスを希望する動作になります。対応することができるでしょうから開始 pagingEnabled
や bounces
両方の設定 YES
その上書き -setContentOffset:
自分の方がクリップいですね。
所属していません StackOverflow