iPhone如何将字符串传递给另一个视图标签?
我的问题是如何将字符串传递给另一个视图标签?我尝试了很多例子,但仍然无法获得我传递的值。
这是我保存的数据。
-(IBAction)Save:(id)sender{
timedata = [datePicker date];
NSLog(@"timedata save is = %@",timedata);
time = [NSString stringWithFormat:@"%@",timedata];
NSLog(@"String time = %@",time);
[self dismissModalViewControllerAnimated:YES];
}
这是我想显示的保存数据。
- (void) viewWillAppear:(BOOL)animated {
show = [[SelectDate alloc]initWithNibName:@"SelectDate" bundle:nil];
show.time = time;
NSLog(@"time = %@",time);
Selectime.text = show.time;
NSLog(@"show.time = %@",show.time);
[super viewWillAppear:animated];
}
My problem is how to pass string to another view label? I got try so many example but still can not get the value where I pass.
here is I save the data.
-(IBAction)Save:(id)sender{
timedata = [datePicker date];
NSLog(@"timedata save is = %@",timedata);
time = [NSString stringWithFormat:@"%@",timedata];
NSLog(@"String time = %@",time);
[self dismissModalViewControllerAnimated:YES];
}
here is I want to show the save data.
- (void) viewWillAppear:(BOOL)animated {
show = [[SelectDate alloc]initWithNibName:@"SelectDate" bundle:nil];
show.time = time;
NSLog(@"time = %@",time);
Selectime.text = show.time;
NSLog(@"show.time = %@",show.time);
[super viewWillAppear:animated];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在 SelectDate viewController 中设置了时间属性,以便可以在其他 viewController 中访问它。
//SelectDate.h
//SelectDate.m
现在您可以像您一样在其他 ViewController 中使用时间。
If you have set property for time in SelectDate viewController so that it can be accessed in other viewControllers.
//SelectDate.h
//SelectDate.m
Now you can use time in other ViewControllers like you are doing.
要获取日期的 NSString 表示形式,您应该查看 NSDateFormatter
示例:
To get a NSString representation of a date you should look at NSDateFormatter
example:
不要访问上一个视图,而是将数据传递到下一个视图:
嗨,我的问题是如何将字符串传递到另一个视图标签?我尝试了很多例子,但仍然无法获得我传递的值。
这是我保存的数据。
这里是你想要显示的保存数据。
Instead of accessing last view, pass your data to your next view:
Hi,My problem is how to pass string to another view label? I got try so many example but still can not get the value where I pass.
here is I save the data.
here is You want to show the save data.