let config = YYSegmentConfig()
let vc = YYSegmentViewController(config)
self.addChild(vc)
vc.view.frame = CGRect(x: 0, y: 130, width: view.bounds.size.width, height: 600)
self.view.addSubview(vc.view)
注意事项:一定要添加 self.addChild(vc),并且在初始化完成之后就得添加

注意事项:在 viewDidLoad() 方法中,在调用 super.viewDidLoad() 方法之前设置 config
oneVc.tabBarItem.title = "第一章"
如果想改变 Title,可直接设置 tabBarItem.title
oneVc.tabBarItem.badgeValue = "112"
如果想改变角标,可直接设置 tabBarItem.badgeValue
当设置 itemIndicatorViewShapeStyle 类型为椭圆和横杆时,itemIndicatorViewWidthChangeStyle不再起作用,默认为横杆
当子view是普通view,想刷新整个页面时,最底层 YYContainerScrollView 是ScrollView,可添加刷新控件,当子view是 tableView 时,可设置刷新方式,整个刷新还是列表刷新
vc.containerScrView.mj_header = MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(refreshControlAction))
当设置了headerView时,需要多一个设置,高度为 headerView 的高度
vc.containerScrView.mj_header.ignoredScrollViewContentInsetTop = 300
指示器view为 YYIndicatorView,可进行自定义,示例代码如下
vc.initDone = { [weak self] in
guard let this = self else {return}
let indicatorViewContentView = this.vc.segmentCtlView.indicatorView.contentView
let mixIndicatorView = MixIndicatorView(frame: indicatorViewContentView.bounds)
indicatorViewContentView.addSubview(mixIndicatorView)
mixIndicatorView.autoresizingMask = [.flexibleWidth,.flexibleHeight]
}
config.itemIndicatorViewShapeStyle = .background(color: UIColor.clear, img: nil)
class MixIndicatorView: UIView {
let ellipseView = UIView()
let crossBarView = UIView()
override init(frame: CGRect) {
super.init(frame: frame)
ellipseView.backgroundColor = UIColor.lightGray.withAlphaComponent(0.8)
ellipseView.frame = CGRect.init(x: 0, y: 0, width: bounds.width, height: 20)
ellipseView.center = CGPoint.init(x: bounds.width/2, y: bounds.height/2)
ellipseView.layer.cornerRadius = 10
ellipseView.autoresizingMask = [.flexibleWidth,.flexibleTopMargin,.flexibleBottomMargin]
addSubview(ellipseView)
let crossBarViewHight:CGFloat = 3
crossBarView.backgroundColor = UIColor.red
crossBarView.frame = CGRect.init(x: 0, y: bounds.height - crossBarViewHight, width: bounds.width, height: crossBarViewHight)
addSubview(crossBarView)
crossBarView.autoresizingMask = [.flexibleWidth,.flexibleTopMargin,.flexibleBottomMargin]
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

oneVc.tabBarItem.title = "第一章"
twoVc.tabBarItem.title = "第二章"
oneVc.tabBarItem.badgeValue = "112"
let headerV = UIImageView(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 300))
headerV.image = UIImage(named: "longzhu")
headerV.contentMode = .scaleAspectFill
headerV.backgroundColor = UIColor.red
let config = YYSegmentConfig()
config.containerControllerArr = [oneVc, twoVc]
let width = view.bounds.size.width / 2
config.segmentBackgroundColor = .yellow
config.headView = headerV
config.itemSpacing = 10
config.itemTitleSelectedScale = 1.5
config.itemWidthStyle = .equalToTitleWidth(margin: 0)
config.segmentControlHeight = 100
config.itemIndicatorViewBackgroundColor = UIColor.blue
config.itemBadgeStyle = .round
config.itemBadgeTitleColor = .blue
config.itemBadgeValueLabelOffset = CGPoint(x: 0, y: -5)
config.itemViewSegmentSelectedStyle = .gradient
config.itemBadgeSize = CGSize(width: 10, height: 10)
config.refreshType = .container
config.segmentControlPositionType = .top
config.itemIndicatorViewWidthChangeStyle = .stationary(baseWidth: width)
config.itemIndicatorViewShapeStyle = .crossBar(widthChangeStyle: .equalToItemWidth(margin: 0), height: 6)
config.isShowItemSeparatorLineView = true
config.itemSeparatorLineTopBottomMargin = (5, 5)
config.itemBadgeTitleFont = 9
let vc = YYSegmentViewController(config)
self.addChild(vc)
vc.view.frame = CGRect(x: 0, y: 130, width: view.bounds.size.width, height: 600)
self.view.addSubview(vc.view)
vc.containerScrView.mj_header = MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(refreshControlAction))vc.containerScrView.mj_header.ignoredScrollViewContentInsetTop = 300
vc.segmentCtlView.clickAnimation = false
vc.pageView.isScrollEnabled = false
vc.segmentCtlView.delegate = self
vc.scrollViewDragTopOffsetYBlock = { (scr, offsetY) in
}
vc.initDone = {
}
当我在Rails控制台中按向上或向左箭头时,出现此错误:irb(main):001:0>/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rb-readline-0.4.2/lib/rbreadline.rb:4269:in`blockin_rl_dispatch_subseq':invalidbytesequenceinUTF-8(ArgumentError)我使用rvm来管理我的ruby安装。我正在使用=>ruby-2.0.0-p247[x86_64]我使用bundle来管理我的gem,并且我有rb-readline(0.4.2)(人们推荐的最少
我正在使用Ruby2.1.1和Rails4.1.0.rc1。当执行railsc时,它被锁定了。使用Ctrl-C停止,我得到以下错误日志:~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.2/lib/spring/client/run.rb:47:in`gets':Interruptfrom~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.2/lib/spring/client/run.rb:47:in`verify_server_version'from~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
?博客主页:https://xiaoy.blog.csdn.net?本文由呆呆敲代码的小Y原创,首发于CSDN??学习专栏推荐:Unity系统学习专栏?游戏制作专栏推荐:游戏制作?Unity实战100例专栏推荐:Unity实战100例教程?欢迎点赞?收藏⭐留言?如有错误敬请指正!?未来很长,值得我们全力奔赴更美好的生活✨------------------❤️分割线❤️-------------------------
说在前面这部分我本来是合为一篇来写的,因为目的是一样的,都是通过独立按键来控制LED闪灭本质上是起到开关的作用,即调用函数和中断函数。但是写一篇太累了,我还是决定分为两篇写,这篇是调用函数篇。在本篇中你主要看到这些东西!!!1.调用函数的方法(主要讲语法和格式)2.独立按键如何控制LED亮灭3.程序中的一些细节(软件消抖等)1.调用函数的方法思路还是比较清晰地,就是通过按下按键来控制LED闪灭,即每按下一次,LED取反一次。重要的是,把按键与LED联系在一起。我打算用K1来作为开关,看了一下开发板原理图,K1连接的是单片机的P31口,当按下K1时,P31是与GND相连的,也就是说,当我按下去时
在我的Character模型中,我添加了:字符.rbbefore_savedoself.profile_picture_url=asset_path('icon.png')end但是,对于数据库中已存在的所有角色,它们的profile_picture_url为nil。因此,我想进入控制台并遍历所有这些并进行设置。在我试过的控制台中:Character.find_eachdo|c|c.profile_picture_url=asset_path('icon.png')end但这给出了错误:NoMethodError:undefinedmethod`asset_path'formain:O
当我进入Rails控制台时,我已将pry设置为加载代替irb。我找不到该页面或不记得如何将其恢复为默认行为,因为它似乎干扰了我的Rubymine调试器。有什么建议吗? 最佳答案 我刚发现问题,pry-railsgem。忘记了它的目的是让“railsconsole”打开pry。 关于ruby-on-rails-带有Pry的Rails控制台,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/question
我正在尝试将$stdout设置为临时写入一个文件,然后返回到一个文件。test.rb:old_stdout=$stdout$stdout.reopen("mytestfile.out",'w+')puts"thisgoesinmytestfile"$stdout=old_stdoutputs"thisshouldbeontheconsole"$stdout.reopen("mytestfile1.out",'w+')puts"thisgoesinmytestfile1:"$stdout=old_stdoutputs"thisshouldbebackontheconsole"这是输出。r
我在思考流量控制的最佳实践。我应该走哪条路?1)不要检查任何东西并让程序失败(更清晰的代码,自然的错误消息):defself.fetch(feed_id)feed=Feed.find(feed_id)feed.fetchend2)通过返回nil静默失败(但是,“CleanCode”说,你永远不应该返回null):defself.fetch(feed_id)returnunlessfeed_idfeed=Feed.find(feed_id)returnunlessfeedfeed.fetchend3)抛出异常(因为不按id查找feed是异常的):defself.fetch(feed_id
我真的只是不确定这意味着什么或我应该做什么才能让网页在我的本地主机上运行。现在它只是显示一个错误,上面写着“我们很抱歉,但出了点问题。”当我运行railsserver并在chrome中打开localhost:3000时。这是控制台输出:StartedGET"/users/sign_in"for127.0.0.1at2013-07-0512:07:07-0400ProcessingbyDevise::SessionsController#newasHTMLCompleted500InternalServerErrorin55msNoMethodError(undefinedmethod`