在iPhone上将数据传递给uiviewcontroller的对象 [英] pass data to object of uiviewcontroller on iPhone

查看:38
本文介绍了在iPhone上将数据传递给uiviewcontroller的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带tableviewcontroller的iPhone应用程序。当您单击某个单元格时,它将使用以下代码打开一个新的uiviewcontroller:

I have an iPhone app with a tableviewcontroller. When you click a certain cell it opens a new uiviewcontroller with this code:

 nextViewController = [[avTouchViewController alloc] initWithNibName:@"avTouchViewController" bundle:nil];

上面的uiviewcontroller称为avTouchViewController,其属性类似于:

The uiviewcontroller above called avTouchViewController has a property that looks like:

IBOutlet SomeObject *controller;

SomeObject是具有所有相关视图属性的对象。

SomeObject is an object with all relevant view properties.

我想从tableviewcontroller传递nsstring参数,将avTouchViewController初始化为someObject。

I would like to pass an nsstring parameter from the tableviewcontroller I initialize the avTouchViewController with to someObject.

我该怎么办?

推荐答案

我是你的问题有点困惑;您说您是在现有的 UITableView 中点击一个单元格时创建的 avTouchViewController ,但是最后一部分描述了

I'm a little confused by your question; you say you're creating your avTouchViewControllers when a cell is tapped inside an existing UITableView, but your last part describes the inverse situation.

基本上,如果要将信息传递给视图控制器,只需为其提供一个可以设置的属性(可能已经是这种情况),例如:

Basically, if you want to pass information to a view controller, just give it a property that can be set (which may already be the case), e.g.:

nextViewController = [[avTouchViewController alloc] initWithNibName:@"avTouchViewController" bundle:nil];
nextViewController.controller = theInstanceOfSomeObjectIWantToPass;

您可能还想重命名控制器属性。对于读者来说,视图控制器具有名为 controller 的属性实际上是 SomeObject * 。同样,您的类名也应大写,即使用 AvTouchViewController 代替 avTouchViewController

You also may want to rename your controller property. To a reader, it doesn't make sense that a view controller has a property called controller which is actually a SomeObject*. As well, your class names should be capitalized, i.e. use AvTouchViewController instead of avTouchViewController.

这篇关于在iPhone上将数据传递给uiviewcontroller的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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