[英]Passing data from a cell to a label on a DetailViewController
I need a little hint on passing data from a cell to a label on a detailViewController. 我需要一些有关将数据从单元格传递到detailViewController上的标签的提示。
Using X-Code 4.6.2, Objective-C with Storyboard. 使用X-Code 4.6.2,Objective-C和Storyboard。
I've got a TableView with all my names init. 我有一个用我所有名字初始化的TableView。 If I click on a cell it goes to the DetailView.
如果单击单元格,则转到DetailView。
I've set up an segue to the DetailView. 我已经为DetailView设置了序列。 But how do I get the information from the selected cell to the Detail View?
但是,如何将信息从选定的单元格获取到详细视图? For Example I click on row 1 and it is supposed to display the name Albert Anker in a label.
例如,我单击第1行,它应该在标签中显示名称Albert Anker。
In my viewController.m 在我的viewController.m中
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"toDetail"]) {
NSString *Name = @"PhoneBooth";
DetailViewController *DVC = [segue destinationViewController];
DVC.nameString = Name;
}
In my DetailViewController.m 在我的DetailViewController.m中
-(void)viewDidLoad
{
[label setText:welcomeString];
}
I've watched several Videos on this subject but none of theme work. 我已经看过几个有关此主题的视频,但是没有主题作品。 The Code above comes from a Tutorial that uses three Buttons and three different named segues.
上面的代码来自一个使用三个按钮和三个不同名称的segue的教程。 I was hoping I could use that for my cell.
我希望可以将其用于我的手机。 I guess I need to use "didSelectRowAtIndexPath" but how?
我想我需要使用“ didSelectRowAtIndexPath”,但是如何?
I hope I was able to describe my problem correctly. 我希望我能够正确地描述我的问题。
I`ve figuered it out. 我已经弄清楚了。
I forgot to @synthsize my label and the NSString. 我忘了@synthsize我的标签和NSString。
THX anyway. THX无论如何。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.