iPhone操作系统实用程序 - Flipside视图和主视图通信 [英] iPhone OS Utility App - Flipside View and Main View communication

查看:111
本文介绍了iPhone操作系统实用程序 - Flipside视图和主视图通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用iPhone 2.1应用程式。我是来自Java背景的Objective C的新功能。

I am currently working on an iPhone 2.1 application. I am new to Objective C, coming from a Java background.

我的应用程序有一个基础的Xcode中使用iPhone SDK的Utility应用程序模板。目前我有一些控件,如UISlider和文本框,在FlipsideView。 UISlider已经有一个方法,当值改变时,使用目标和选择器被调用。但是,我也想从MainView中读取UISlider和文本框的当前(或最后)值。

My application has as a base the Utility Application template available in Xcode with the iPhone SDK. Currently I have some controls, such as an UISlider and text box, in the FlipsideView. The UISlider already has a method which is being called when the value changes, using targets and selectors. However, I would also like to be able to read, from the MainView, the current (or last) value of the UISlider and textbox.

请记住我是新的在Mac上的开发,并希望任何指导,我应该在哪里查找这些信息,无论是通过使用代表,或者我缺少一个明显的模板的结构中的一些东西。

Keep in mind I am new to development on a Mac, and would appreciate any guidance as to where I should look up such information, be it through the use of delegates or perhaps I am missing something obvious in the structure of the template.

更新:
我看看结构,并有一些更多的细节:UISlider正在FlipsideView.m中创建。我注意到完成按钮是从RootViewController.m创建的,也许我应该移动UISlider代码。我可能不正确地使用视图来保存在控制器中更合适的代码。

UPDATE: I am taking a look at the structure and have some more details: The UISlider is being created in FlipsideView.m. I noticed that the Done button is created from RootViewController.m and probably I should move the UISlider code over there. I may incorrectly be using the View to keep code that would be more appropiate in a Controller.

推荐答案

基础对象与控制器的值。一般来说,滑块属于视图层 - 它是一个显示元素。然而,调整滑块产生的动作是控制器的一个组件,它应该回到你的模型中来更新一个值。我强烈建议在一张纸上绘图箱,并尽量为应用程序的图层生成一个清晰的分隔 - 在这种情况下,将为该实用程序的每个侧生成两个视图,通过控制器,到模型。然后,移动滑块的动作将立即更新背面的模型。 iPhone开发者网站上的Cocoa Fundamental视频演示了这个效果很好。

Ultimately you should be updating some underlying object with the values from the controller. In general, the slider belongs in the view layer - it's a display element. The action that adjusting the slider produces, however, is a component of the controller and it should fire back into your model to update a value. I highly recommend drawing boxes on a sheet of paper and trying to produce a clean a separation as possible for your application's layers - doing so in this case would produce two views for each "side" of the utility which would, via a controller, relate to a model. Then, the act of moving the slider would "instantly" update the model on the back. The Cocoa Fundamental video on the iPhone developer site demonstrates this to great effect.

这篇关于iPhone操作系统实用程序 - Flipside视图和主视图通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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