Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift下加号无法显示 #226

Closed
wongwenlei opened this issue Dec 25, 2017 · 15 comments
Closed

swift下加号无法显示 #226

wongwenlei opened this issue Dec 25, 2017 · 15 comments
Labels

Comments

@wongwenlei
Copy link

Base Info for this issue

  1. Version:v1.17.4
  2. Language:Swift4.0
  3. iOS System Version:iOS11.2
  4. Prototype(是否是真机):NO
  5. Issue Type:Crash、Bug、Enhancement(希望能支持一个新需求)、Q-A

1. How to repeat the problem.

中间的plus按钮无法显示

2. Please help me in this way.

swift使plus按钮正常显示

3. Here is a Demo.

通过邮箱发送demo

4. Here is my Debug log

@WeMadeCode
Copy link

我也出现了这个问题

@ChenYilong
Copy link
Owner

ChenYilong commented Dec 26, 2017

从1.17.4版本起,需要通过规定的初始化方法来进行初始化,

比如下面的系列初始化方法:

- (instancetype)initWithViewControllers:(NSArray<UIViewController *> *)viewControllers
                 tabBarItemsAttributes:(NSArray<NSDictionary *> *)tabBarItemsAttributes;

+ (instancetype)tabBarControllerWithViewControllers:(NSArray<UIViewController *> *)viewControllers
                             tabBarItemsAttributes:(NSArray<NSDictionary *> *)tabBarItemsAttributes;

- (instancetype)initWithViewControllers:(NSArray<UIViewController *> *)viewControllers
                 tabBarItemsAttributes:(NSArray<NSDictionary *> *)tabBarItemsAttributes
                           imageInsets:(UIEdgeInsets)imageInsets
               titlePositionAdjustment:(UIOffset)titlePositionAdjustment;

+ (instancetype)tabBarControllerWithViewControllers:(NSArray<UIViewController *> *)viewControllers
                             tabBarItemsAttributes:(NSArray<NSDictionary *> *)tabBarItemsAttributes
                                       imageInsets:(UIEdgeInsets)imageInsets
                           titlePositionAdjustment:(UIOffset)titlePositionAdjustment;

- (instancetype)initWithViewControllers:(NSArray<UIViewController *> *)viewControllers
                 tabBarItemsAttributes:(NSArray<NSDictionary *> *)tabBarItemsAttributes
                           imageInsets:(UIEdgeInsets)imageInsets
               titlePositionAdjustment:(UIOffset)titlePositionAdjustment
                               context:(NSString *)context;

+ (instancetype)tabBarControllerWithViewControllers:(NSArray<UIViewController *> *)viewControllers
                             tabBarItemsAttributes:(NSArray<NSDictionary *> *)tabBarItemsAttributes
                                       imageInsets:(UIEdgeInsets)imageInsets
                           titlePositionAdjustment:(UIOffset)titlePositionAdjustment
                                           context:(NSString *)context;

现在仓库里的swift-demo还未更新,稍后会更新。

@wongwenlei @WeMadeCode

@ChenYilong ChenYilong added the Q-A label Dec 26, 2017
@ChenYilong
Copy link
Owner

另外也欢迎帮忙修改下仓库里的swift demo,提一个pr。

@WeMadeCode
Copy link

@ChenYilong 多谢指点,仓库里的Swift版本有点老了,最新写了个https://github.com/WeMadeCode/CYLTabBarController-Swift
Swift版本的简单用法,希望指点与采纳

@ChenYilong
Copy link
Owner

@WeMadeCode 十分感谢,另外你再检查下你的demo,截止你的第三个 commit :18355f87e99bb09f1b5ebd10ddd11b451c129ffc demo无法这个正常运行,pod install也是失败的,请检查target name设置是否与podfile 里的设置能够匹配。

@WeMadeCode
Copy link

@ChenYilong Sorry 由于我修改工程名的操作,造成了这个问题
https://github.com/WeMadeCode/CYLTabBarController-Swift
我重新传了一份
麻烦您了。

@ChenYilong
Copy link
Owner

@WeMadeCode 已经采纳,并在文档中进行了署名,感谢。我的仓库中也已经上传了你的 最新版 ,代码未做修改,欢迎验证下我仓库中的版本是否属于你的预期。后期如果你这边有更新的话,欢迎提PR,再次表示感谢。

@WeMadeCode
Copy link

@ChenYilong 非常感谢 我以后将继续学习CYLTabBarController,并将提交更多的Swift版本功能

@eveloson
Copy link

@ChenYilong 那么StoryBoard创建的怎么初始化呢

@kcchen2012
Copy link

我也遇到一样的疑问,“那么StoryBoard创建的怎么初始化呢?”

@rxvincent
Copy link

同样的问题,请问通过StoryBoard创建的有没有办法解决?

@rxvincent
Copy link

rxvincent commented Apr 3, 2019

自行解决,在Storyboard连接的类里的viewDidLoad(),我加入了以下的代码
不知道这样写会不会导致崩溃类问题,iOS12的iphoneX成功

super.viewDidLoad()
setBarItem()//设置图标名称
setViewControllers()//将原本连接到children的vc连接到viewControllers
MainFunctionButton.register()//注册加号
(tabBar as! CYLTabBar).context = "CYLTabBarController"//手动设置context

@ChenYilong
Copy link
Owner

Storyboard的tabbar在图形界面也可以自定义归属类

@rxvincent
Copy link

应该说,在Storyboard指定tabBarController的归属类后,不会调用任何init方法,而跟plusButton相关的逻辑我看到放在了setContext里面,如果是用Storyboard创建是不会调用这个方法的

@ChenYilong
Copy link
Owner

多谢提供解决方案

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants