1

は、私はこのようなUIを持つアプリケーションを設計したい: enter image description hereUITabControllerの各タブがある多くのビューコントローラ

一番下で、私はそれがUITabbarController知っています。各タブには、BEAT、TOP、FUNなどの多くのビューコントローラがあります。各タブには、さまざまなビューコントローラがあります。 水平スクロールの場合は、BEATからTOPへ、FUNへと変更できます。 どうすればこのように設計できますか?どのView Controllerを使用すればいいですか?それはUITabControllerのUIPageControllerのようですが、UIPageControllerを使って、BEAT、TOP、FUN ...の最下部(。)のドットをどのように置き換えるかわかりません。

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

答えて

1

代わりに、UISwipeGesture(左/右)をビューに追加し、スワイプアクションでビューコントローラをプッシュまたはポップできます。 ViewController.m

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [self setupSwipeGestures]; 
} 

-(void)setupSwipeGestures 
{ 
    _leftSwipe=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(next)]; 
    [_leftSwipe setDirection:UISwipeGestureRecognizerDirectionLeft]; 

    _rightSwipe =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(previous)]; 
    [_rightSwipe setDirection:UISwipeGestureRecognizerDirectionRight]; 

    [self.view addGestureRecognizer:_leftSwipe]; 
    [self.view addGestureRecognizer:_rightSwipe];  
} 

- (void) previous 
{ 
    // perform pop to get previous viewController 
    // i.e [self.navigationController popViewControllerAnimated:YES]; 

} 

- (void) next 
{ 
    // perform push to get next viewController 
    // i.e  [self.navigationController pushViewController:viewController animated:YES]; 
} 

ViewController.h

@property (retain, nonatomic) UISwipeGestureRecognizer * leftSwipe; 
@property (retain, nonatomic) UISwipeGestureRecognizer * rightSwipe; 

あなたはすべてのコントローラで上記のコードを使用したい場合は、あなた自身のViewControllerを定義し、その中にコードの上に貼り付けることがその後、上記の機能が必要なすべてのviewControllerを継承します。

1

タブコントローラの各タブでXLPagerTabStripライブラリを使用できます。素晴らしいライブラリでも、タブのプロパティを保持するだけでなく、個々のページセクションをスワイプすることができるアンドロイドに似たスワイプ機能を提供します。

+0

良いライブラリ。ありがとうございました。 – Brave

関連する問題