-1

まず、localScopeアプリからこの写真を見てください:

localScope

私は2つの(単純な?)質問があります:

  1. このようにアイコンをページ付けするにはどうすればよいですか?

  2. 魔女のアイコンが「選択されている」ことを検出するにはどうすればよいですか

ありがとうございました。

4

2 に答える 2

1

最初の質問への回答:スクロールビューをページサイズと同じ大きさにし、その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;
于 2012-07-05T17:37:10.397 に答える
0

クリーンでメモリ効率の高いアプローチの1つは、UINavigationControllerUIToolBarのようにすることです-

ここに画像の説明を入力してください

ユーザーがボタンをタップして押すと、UIToolBarその特定のボタンが呼び出されviewControllerます。

画像に表示されているものに近いルックアンドフィールを実現できることが明確になっていることを願っています。機能について話します。

于 2012-07-05T17:32:07.157 に答える