【发布时间】:2012-11-28 10:24:58
【问题描述】:
我在 DetailsOfPeopleViewController 的标签中显示 AddNotesViewController Class 的字符串值时遇到问题。
我想要做的就是我们在 1 个类的 UITextView 中输入的任何内容,都应该显示在另一个类的 UILabel 中。
在文件AddNotesViewController.h
UITextView *txtView;
@property(nonatomic,retain)IBOutlet UITextView *txtView;
在文件AddNotesViewController.m
@synthesize txtView;
之后,当我点击标签栏项目“保存”时,它应该保存在数据库中, 它保存到数据库并显示值,但它没有将值传递给
DetailsOfPeopleViewController.
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
NSLog(@"Tabbar selected itm %d",item.tag);
switch (item.tag) {
case 0:
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NotesTable *crashNotInvolvingObj11 = (NotesTable *)[NSEntityDescription
insertNewObjectForEntityForName:@"NotesTable" inManagedObjectContext:[appDelegate managedObjectContext]];
// CameraViewController *camera=[[CameraViewController alloc] init];
crashNotInvolvingObj11.personNote=[NSString stringWithFormat:@"%@",txtView.text];
DetailsOfPeopleViewController *detail=[DetailsOfPeopleViewController alloc];
detail.testPersonNotesStr =[NSString stringWithFormat:@"%@",txtView.text];
//(value of testPersonNotesStr is DISPLYING here... )
[appDelegate saveContext];
[detail release];
break;
..................
}
在DetailsOfPeopleViewController.h
NSString *testPersonNotesStr;
UILabel *PersonNotesLbl;
@property(nonatomic,retain)IBOutlet UILabel *PersonNotesLbl;
@property(nonatomic,retain) NSString *testPersonNotesStr;
在DetailsOfPeopleViewController.m
@synthesize PersonNotesLbl;
@synthesize testPersonNotesStr;
- (void)viewDidLoad
{
[super viewDidLoad];
[PersonNotesLbl setText:testPersonNotesStr];
NSLog(@"PERSON NOTE is........ %@",testPersonNotesStr);
//(value of testPersonNotesStr is NOT DISPLYING here..... )
}
请指导我在哪里做错了。
【问题讨论】:
-
你能告诉我你使用哪个代码导航到 DetailsOfPeopleViewController