gpt4 book ai didi

ios - iOS Swift 中的 Android 选项卡

转载 作者:行者123 更新时间:2023-11-28 08:09:11 25 4
gpt4 key购买 nike

我正在像 iOS Swift3 中的 android 一样使用 Tab。我已成功安装 XLPagerTabStrip 但遇到问题:

terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'child1'

这是我的代码:

import UIKit
import XLPagerTabStrip
class ParentViewController: ButtonBarPagerTabStripViewController {

let customPurpleColor = UIColor(red:0.13 , green : 0.03 , blue : 0.25 , alpha : 1.0)
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
settings.style.buttonBarBackgroundColor = .white
settings.style.buttonBarItemBackgroundColor = .white
settings.style.selectedBarBackgroundColor = customPurpleColor
settings.style.buttonBarItemFont = .boldSystemFont(ofSize: 14)
settings.style.selectedBarHeight = 1.0
settings.style.buttonBarMinimumLineSpacing = 0
settings.style.buttonBarItemTitleColor = .black
settings.style.buttonBarItemsShouldFillAvailiableWidth = true
settings.style.buttonBarLeftContentInset = 0
settings.style.buttonBarRightContentInset = 0
changeCurrentIndexProgressive = { [weak self] (oldCell : ButtonBarViewCell? , newCell : ButtonBarViewCell?
, progressPercentage: CGFloat, changeCurrentIndex : Bool , animated : Bool) -> Void in
guard changeCurrentIndex == true else {return}
oldCell?.label.textColor = .black
newCell?.label.textColor = self?.customPurpleColor
}
}
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
let child_1 = UIStoryboard(name : "Main" , bundle : nil).instantiateViewController(withIdentifier: "child1")
let child_2 = UIStoryboard(name : "Main" , bundle : nil).instantiateViewController(withIdentifier: "child2")
return [child_1 , child_2]
}
}

ChildViewController1.swift:

import UIKit
import XLPagerTabStrip


class ChildViewController1: UIViewController , IndicatorInfoProvider{
func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
return IndicatorInfo(title : "child1")
}
}

ChildViewController2.swift:

import UIKit
import XLPagerTabStrip

class ChildViewController2: UIViewController , IndicatorInfoProvider{
func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
return IndicatorInfo(title : "child1")
}
}

我在 Main.storyboard 中使用了 UIScrollViewcollectionView 到 buttonBarView。因为我是 iOS 开发的新手,所以我不明白为什么会发生此错误?

最佳答案

您需要如下设置 ViewController 的标识符:

enter image description here

关于ios - iOS Swift 中的 Android 选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44159233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com