まず、localScopeアプリからこの写真を見てください:
私は2つの(単純な?)質問があります:
このようにアイコンをページ付けするにはどうすればよいですか?
魔女のアイコンが「選択されている」ことを検出するにはどうすればよいですか
ありがとうございました。
まず、localScopeアプリからこの写真を見てください:
私は2つの(単純な?)質問があります:
このようにアイコンをページ付けするにはどうすればよいですか?
魔女のアイコンが「選択されている」ことを検出するにはどうすればよいですか
ありがとうございました。
最初の質問への回答:スクロールビューをページサイズと同じ大きさにし、そのpagingEnabled
プロパティを有効にしてから、何らかの方法で要素を表示し、境界外のタッチに応答するようにする必要があります。このコードとこれらのリンクを参照してください。
@interface SmallPagedScrollView: UIScrollView <UIScrollViewDelegate> {
UIEdgeInsets responseInsets;
NSMutableArray *items;
}
@implementation SmallPagedScrollView
@synthesize responseInsets;
- (id)init
{
if ((self = [super initWithFrame:CGRectMake(x, y, w, h)]))
{
self.backgroundColor = [UIColor clearColor];
self.pagingEnabled = YES;
self.showsHorizontalScrollIndicator = NO;
self.showsVerticalScrollIndicator = NO;
self.clipsToBounds = NO;
CGFloat hInset = 3 * self.width / 2;
self.responseInsets = UIEdgeInsetsMake(0.0f, hInset, 0.0f, hInset);
self.delegate = self;
items = [[NSMutableArray alloc] init];
}
return self;
}
- (void)dealloc
{
[items release];
[super dealloc];
}
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
CGPoint parentLocation = [self convertPoint:point toView:self.superview];
CGRect responseRect = self.frame;
responseRect.origin.x -= self.responseInsets.left;
responseRect.origin.y -= self.responseInsets.top;
responseRect.size.width += self.responseInsets.left + self.responseInsets.right;
responseRect.size.height += self.responseInsets.top + self.responseInsets.bottom;
return CGRectContainsPoint(responseRect, parentLocation);
}
フレームサイズよりも小さい増分でのUIScrollViewのページング(スプリットの回答)も参照してください。
2番目の質問への回答:次の式を使用して、選択したページを計算できます。
int selectedIndex = (scrollView.contentOffset + scrollView.size.width / 2) / scrollView.size.width;
クリーンでメモリ効率の高いアプローチの1つは、UINavigationController
&UIToolBar
のようにすることです-
ユーザーがボタンをタップして押すと、UIToolBar
その特定のボタンが呼び出されviewController
ます。
画像に表示されているものに近いルックアンドフィールを実現できることが明確になっていることを願っています。機能について話します。