跨平台罗兹问题
我已经对罗兹(跨平台)进行了很好的设置,并且我在设置本身中取得了成功。使用“$rake run:iphone”命令我可以成功执行演示项目。现在我想处理一些问题,例如我想在一个屏幕中进行算术计算,并且我想在下一个屏幕中显示答案。 我怎样才能得到那个?请给些建议?
i have made setup for the rhodes (cross platform) very well and i got the success in setup itself.with the "$rake run:iphone" command i can get the successful execution of demo project.Now i want to handle some issues like i want to do arithmatic calculations in one screen and i want to show the answer in next screen.
How would i get that? give the suggestions please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道您发布此内容已经有一段时间了,但我希望它有所帮助,或者其他人可能会发现它有帮助。
假设您知道如何在第一页上进行计算,我们将其称为索引页(因为它在罗德岛中正确命名),您可以按如下方式进行操作:
在开始之前,请确保存储了索引页的结果变量中的计算,对于这些指令,我们将其称为 $result。
1) 创建一个新的 .erb 文件,用于表示结果页面(如果您创建了模型,则已经有一个名为“show”的 .erb 文件,并且可以轻松修改和使用该文件)。在此示例中,我们将该页面称为“结果”。
2)在控制器中创建一个新的 def - 让我们称之为“计算”。这可能看起来像这样:
defcalculate
[进行您想要的任何计算]
$result = [计算结果]
渲染:动作=> :结果, :返回 => url_for(:action => :index)
end
这一行:
render :action => :结果, :返回 => url_for(:action => :index)
会将您发送到结果页面并定义智能手机后退按钮导航回索引页面的操作。
3)确保索引页面上的“获取结果按钮”调用新的定义。对于简单的链接,它可能看起来像这样:
获取结果
4) 在结果页面显示结果。
索引页中的变量在结果页中仍然可用,因此您可以通过将以下行添加到结果页 (result.erb) 来显示结果:
<%= $result.to_s % > (这会将您的结果作为字符串插入)。
I know that it is some time since you posted this, but I hope it helps or that others may find it helpfull.
Assuming that you know how to make the calculations on the first page, lets call it the index-page (as it is properly named in rhodes), you can do it as follows:
Before you begin make sure that you store the result of your calculations in a variable, for these instructions lets call it $result.
1) Create a new .erb file which you want to represent the result page (if you created a model, you already have a .erb file called "show" and could just as easily modify and use that). In this example - lets call the page "result".
2) Create a new def in your controller - lets call it "calculate". This could look something like this:
def calculate
[do any calulations you should desire]
$result = [result of calculations]
render :action => :result, :back => url_for(:action => :index)
end
This line:
render :action => :result, :back => url_for(:action => :index)
will send you to your result page and define the action for the smartphone's backbutton to navigate back to your index-page.
3) Make sure that your "get-result-button" on your index-page invokes your new def. For a simple link this could for example look something like this:
<a href="<%= url_for :action => :calculate %>">get result</a>
4) Display the result in the result page.
Your variable from your index-page is still available in the result-page, so you can show the result by adding the following line to your result-page (result.erb):
<%= $result.to_s %> (this will insert your result as a string).