質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

2回答

986閲覧

navigationcontrollerの上にXLPagerTabStripwを使いたい

ROKIDOG

総合スコア20

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2019/08/22 11:37

XLPagerTabStripwを使って1枚目の画像のようにページをスライドさせて画面を切り替えるようにしたいです。

初めに作ったものはnavigationcontrollerを使っておらず2枚目のようにタイトルが上に行き過ぎてしまいました。
そこでnavigationcontrollerを使いnavigation bar の下に表示させようと思ったのですが、3枚目の画像のようにうまく表示されません。

試したこと
ScrollViewをcontainerViewに設定したことの確認
Collection Viewのクラスを「ButtonBarView」と結びつけ、Moduleは「XLPagerTabStrip」であることの確認
下のコードで色々数字を変えてみましたがうまく行きませんでした。。

何かアドバイス頂けると幸いです。

1したいこと
イメージ説明
2実際のもの(NavigationControllerなし)
イメージ説明
3実際のもの(NavigationControllerあり)
イメージ説明
4 storybord
イメージ説明

import UIKit import XLPagerTabStrip class QuestionViewController: ButtonBarPagerTabStripViewController { override func viewDidLoad() { configureButtonBar() super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { //管理されるViewControllerを返す処理 let firstVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Movie") let secondVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Book") let thirdVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Music") let childViewControllers:[UIViewController] = [firstVC, secondVC, thirdVC] return childViewControllers } func configureButtonBar() { // Sets the background colour of the pager strip and the pager strip item settings.style.buttonBarBackgroundColor = .white settings.style.buttonBarItemBackgroundColor = .white // Sets the pager strip item font and font color settings.style.buttonBarItemFont = UIFont(name: "Helvetica", size: 16.0)! settings.style.buttonBarItemTitleColor = .gray // Sets the pager strip item offsets settings.style.buttonBarMinimumLineSpacing = 0 settings.style.buttonBarItemsShouldFillAvailableWidth = true settings.style.buttonBarLeftContentInset = 0 settings.style.buttonBarRightContentInset = 0 // Sets the height and colour of the slider bar of the selected pager tab settings.style.selectedBarHeight = 3.0 settings.style.selectedBarBackgroundColor = .orange // Changing item text color on swipe changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in guard changeCurrentIndex == true else { return } oldCell?.label.textColor = .gray newCell?.label.textColor = .orange } } } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

buttan var view との結びつきは出来ていましたが、container view
との結びつきができていませんでした。。

結びつけ、storybiordでbuttan var view の位置をうまく調整したらうまくいってくれました!

投稿2019/09/08 07:26

ROKIDOG

総合スコア20

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

何を参考に作りましたか???
https://qiita.com/KikurageChan/items/35593dc3aac8d694db8e

を参考に作ればできそうに見えますが、、、
constraintsは正しく設定していますか?
classは正しく設定していますか?
Referencing Outletsもきちんと繋げていますか???

ご確認ください。

投稿2019/08/24 01:58

編集2019/08/24 02:10
hameji

総合スコア1380

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ROKIDOG

2019/09/08 07:28

回答ありがとうございました! なんとか解決いたしました。。。 URL先も参考にさせてもらいました! 本当にありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問