到目前为止,这是我的代码:
class WarmPushPageViewController: UIPageViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
// Do any additional setup after loading the view.
let feedViewController = storyboard!.instantiateViewController(withIdentifier: "FeedViewController")
setViewControllers([feedViewController], direction: .forward, animated: false, completion: nil)
let hashtagsButton = UIButton(frame: CGRect(x: 8, y: self.view.frame.height - 30, width: 70, height: 20))
hashtagsButton.setTitle("Hashtags", for: .normal)
hashtagsButton.tintColor = UIColor.blue
self.view.addSubview(hashtagsButton)
self.view.bringSubview(toFront: hashtagsButton)
let feedButton = UIButton(frame: CGRect(x: self.view.frame.width/2, y: self.view.frame.height - 30, width: 50, height: 20))
feedButton.setTitle("Feed", for: .normal)
feedButton.tintColor = UIColor.blue
self.view.addSubview(feedButton)
self.view.bringSubview(toFront: feedButton)
let userButton = UIButton(frame: CGRect(x: self.view.frame.width-65, y: self.view.frame.height - 30, width: 50, height: 20))
userButton.setTitle("User", for: .normal)
userButton.tintColor = UIColor.blue
self.view.addSubview(userButton)
self.view.bringSubview(toFront: userButton)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
extension WarmPushPageViewController: UIPageViewControllerDataSource {
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if let _ = viewController as? UserViewController {
let feedViewController = storyboard!.instantiateViewController(withIdentifier: "FeedViewController")
return feedViewController
} else if let _ = viewController as? FeedViewController {
let hashtagsViewController = storyboard!.instantiateViewController(withIdentifier: "HashtagsViewController")
return hashtagsViewController
}
return nil
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if let _ = viewController as? HashtagsViewController {
let feedViewController = storyboard!.instantiateViewController(withIdentifier: "FeedViewController")
return feedViewController
} else if let _ = viewController as? FeedViewController {
let userViewController = storyboard!.instantiateViewController(withIdentifier: "UserViewController")
return userViewController
}
return nil
}
}
出于某种原因,一旦我到达末页的边缘,标签就会出现在边缘:
标签也出现在我的 View 层次结构中,但我的假设是问题可能出在此处:
最终目标是使用 Sketch Assets 创建我自己的自定义按钮,在其中触摸特定按钮的内部将转到相应的页面。
最佳答案
引用链接:https://spin.atomicobject.com/2016/02/11/move-uipageviewcontroller-dots/
关于ios - 尝试向 UIPageViewController 添加按钮,但按钮不会显示,即使它们在 View 层次结构中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41189092/
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何
我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>
我有一个ModularSinatra应用程序,我正在尝试将Bootstrap添加到应用程序中。get'/bootstrap/application.css'doless:"bootstrap/bootstrap"end我在views/bootstrap中有所有less文件,包括bootstrap.less。我收到这个错误:Less::ParseErrorat/bootstrap/application.css'reset.less'wasn'tfound.Bootstrap.less的第一行是://CSSReset@import"reset.less";我尝试了所有不同的路径格式,但它
设置:狂欢ruby1.9.2高线(1.6.13)描述:我已经相当习惯在其他一些项目中使用highline,但已经有几个月没有使用它了。现在,在Ruby1.9.2上全新安装时,它似乎不允许在同一行回答提示。所以以前我会看到类似的东西:require"highline/import"ask"Whatisyourfavoritecolor?"并得到:Whatisyourfavoritecolor?|现在我看到类似的东西:Whatisyourfavoritecolor?|竖线(|)符号是我的终端光标。知道为什么会发生这种变化吗? 最佳答案
我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R