我怎么能保存按钮presses成不同的.xib并查看它们? [英] How can I store button presses into a different .xib and view them?

查看:157
本文介绍了我怎么能保存按钮presses成不同的.xib并查看它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个科学计算器应用程序,我已经得到了所有工作的按钮和数学。
我所要做的是添加将显示所有的计算器已执行的操作的第二个观点。最好的方法(我能想到的)是存储所有的按钮presses并在此次视图显示它们。但我不知道如何通过视图之间按钮presses。

I am creating a scientific calculator application, I have got all of the buttons working and the math. What I am trying to do is add a second view that will show all the actions that the calculator has performed. The best way (I could think of) was to store all the button presses and display them in this secondary view. But I do not know how to pass button presses between views.

我也做了教程从数据域将数据传递到标签和类似于它应该如何工作的事情,但结果需要在更多的按钮pssed与数据字段来的NSString方法$ P $到不可替代的。

I have done the tutorials on passing data from datafields to labels and that is something similar to how it should work, but the results need to not be replaced when more buttons are pressed as with the datafield to NSString method.

任何帮助是极大AP preciated。如果有什么不清楚,请让我知道。

Any help is greatly appreciated. If something is unclear please let me know.

推荐答案

您不一定需要两个视图控制器。您可以使用主视图作为容器(称之为containerView)。在其中放置另外两个UIViews每次占用整个视图。确保一个不是在另一个内。它们应在containerView内的对等体的水平。一个是你当前视图(称之为calculatorView)。另一种是为动作视图(称之为actionsView)。添加一个按钮到每个两种观点具有关联IBAction为你的意见之间进行转换。你的程序将永远留在同一个视图控制器;控制器之间没有传递必要的。您过渡是这样的:

You don't necessarily need two view controllers. You can use your main view as a container (call it containerView). Place two other UIViews in it with each taking up the whole view. Make sure that one is not inside the other. They should be at a peer level inside the containerView. One is you your current view (call it calculatorView). The other is a view for the the actions (call it actionsView). Add a button to each of the two views with an associated IBAction to transition between the views. Your program will always remain in the same view controller; no passing between controllers in necessary. You transition like this:

[UIView animateWithDuration:1.0 delay:nil options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
    [calculatorView setHidden:YES];
    [actionsView setHidden:NO];
} completion:nil];

[UIView animateWithDuration:1.0 delay:nil options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
    [calculatorView setHidden:NO];
    [actionsView setHidden:YES];
} completion:nil];

虽然可以使用两个视图控制器,这是一个很好的设计模式去学习,这是一个简单的解决方案,避免了在你的计算器应用程序的复杂性。

While you can use two view controller and it is a good design pattern to learn, this is an easy solution that avoids that complexity in your calculator App.

这篇关于我怎么能保存按钮presses成不同的.xib并查看它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆