gpt4 book ai didi

ios - CarbonKit CarbonTabSwipeNavigation,Viewcontrollers 未正确对齐

转载 作者:可可西里 更新时间:2023-10-31 23:43:46 26 4
gpt4 key购买 nike

我正在使用 ermalkaleci 的 Carbonkit 的 CarbonTabSwipeNavigation,当 View 加载时, View Controller 正确对齐,然后当切换到第二个 View Controller 时,第二个 View Controller 的对齐是正确的,但是当滚动回第一个 View Controller 时,它是对齐的错误,第二个 View Controller 的一小部分是可见的。尝试了我能找到的一切,但到目前为止还没有成功。

我当前的设置使用的是工具栏,但使用 insertIntoRootViewController 插入时的行为相同 :(

    class func setupCarbonPages(carbonSwipeTabsItem:CarbonTabSwipeNavigation,tabTitles:[String],totalWidth: CGFloat) -> CarbonTabSwipeNavigation{

// Setup the default style
carbonSwipeTabsItem.toolbar.translucent = false
carbonSwipeTabsItem.setIndicatorColor(AppConfig.BLUECOLOR)
carbonSwipeTabsItem.setNormalColor(AppConfig.BLUECOLOR)
carbonSwipeTabsItem.setSelectedColor(AppConfig.BLUECOLOR, font: UIFont.boldSystemFontOfSize(14))
carbonSwipeTabsItem.setTabExtraWidth(CGFloat(0))
carbonSwipeTabsItem.setNormalColor(AppConfig.BLUECOLOR, font: AppConfig.REGULAR_FONT_16)
carbonSwipeTabsItem.setSelectedColor(AppConfig.BLUECOLOR, font: AppConfig.REGULAR_FONT_16)

// Assign tab width & preload all data
let menuTabItems:UInt = UInt(tabTitles.count)
let tabWidth = (totalWidth / CGFloat(menuTabItems))
for index:UInt in 0 ..< menuTabItems {
carbonSwipeTabsItem.carbonSegmentedControl!.setWidth(tabWidth, forSegmentAtIndex: Int(index))
}

return carbonSwipeTabsItem
}

然后在我的 View Controller 中:

private func setupSwipableTabs(){
let width = self.view.frame.width

carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: menuTabTitles as [AnyObject], toolBar: self.toolBar,delegate: self)
Helper.setupCarbonPages(carbonTabSwipeNavigation, tabTitles: menuTabTitles, totalWidth: self.view.frame.width).insertIntoRootViewController(self)
Helper.preloadCarbonPages(carbonTabSwipeNavigation, tabs: 2)
}

图书馆:https://github.com/ermalkaleci/CarbonKit

Problem(红线是第二个viewcontroller的一部分)

最佳答案

尝试在主线程上设置碳套件代码

dispatch_async(dispatch_get_main_queue(), {
let width = self.view.frame.width

carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: menuTabTitles as [AnyObject], toolBar: self.toolBar,delegate: self)
Helper.setupCarbonPages(carbonTabSwipeNavigation, tabTitles: menuTabTitles, totalWidth: self.view.frame.width).insertIntoRootViewController(self)
Helper.preloadCarbonPages(carbonTabSwipeNavigation, tabs: 2)
})

关于ios - CarbonKit CarbonTabSwipeNavigation,Viewcontrollers 未正确对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37391611/

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