无法将UITableViewCell didSelectRowAtIndexPath数据传递给另一个视图控制器

时间:2012-03-03 10:14:04

标签: iphone objective-c ios uitableview uiviewcontroller

我目前在主视图控制器中有一个UITableView。我希望将所选行的数据传递给项目中的另一个视图控制器。

这是我到目前为止所得到的,尽管有一个错误。为什么是这样?我在.h文件中引用了类和头文件。 enter image description here

我真的很感激这方面的一些帮助,因为我已经尝试了我能想到的一切。

3 个答案:

答案 0 :(得分:2)

Simply synthesize the object in the destination view.
It will work fine...

like:
in .h

 @property(nonatomic, retain) UILabel *note;

in .m 
@synthesize note;

答案 1 :(得分:1)

非常简单,我认为笔记是UILabel,

根据你的错误 请在AddNote中使用此代码。 h文件

     NSString  *noteStr; //Ios 4
     IBoutlet   UILabel *note;


@property(nonatomic, retain) NSString  *noteStr; //Ios 4
@property(nonatomic, retain) UILabel *note;



@property(nonatomic, strong) NSString   *noteStr;
 @property(nonatomic, strong) UILabel *note;   //Ios 5

在AddNote中。 .m文件

@synthesize note,noteStr;

self.note.text=noteStr; //in ViewWillAppear

某些时间应用程序崩溃因为内存如果您在IOS中工作4请更正此代码

an.noteStr - [selectNote retain];

答案 2 :(得分:0)

声明静态变量以供全局使用。 使用关键字extern

Create Common.h

extern NSMutableArray *gMyBasketCollectionList;


common.m

NSMutableArray *gMyBasketCollectionList;


Use This Mutable Aarray to Store Your Data and Display in Any other
include common.h in First View And SecondView 
Add Object to mutable Array in First View And 
Show SecondView And Display access that Array