I have a TableView that load JSON content from web.
I use AFNetworking and JSONModel. And I use this tutorial do Receive and Parse the Data
Here is the code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = #"CellIdentifier";
__weak ProgramacaoTableCell *cell = (ProgramacaoTableCell *)[self.tableView dequeueReusableCellWithIdentifier:identifier];
ProgramacaoModel* programacao = _programacao.programacaoArray[indexPath.row];
// NameLabel is the Label in the Cell.
cell.nameLabel.text = [NSString stringWithFormat:#"%#", programacao.atracao ];
return cell;
}
I want to know how pass this data to a Detail ViewController.
In my DetailViewController i have the properties to receive the data.
#property (nonatomic, strong) IBOutlet UILabel *programacaoNomeLabel;
You can access to your controller through your navigation:
NSArray* vcStack=[self appDelegate].myNavigationController.viewControllers;
UIViewController* vcUnder;
if(vcStack.count > 0)
vcUnder=[vcStack objectAtIndex:(vcStack.count-1)];
// -1 depends when you called your controller that's why we test the kind of class
if([vcUnder isKindOfClass:[DetailViewController class]]){
((DetailViewController*) vcUnder). programacaoNomeLabel = #"some data";
}
I find the answer
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Pass the selected object to the new view controller.
if ([[segue identifier] isEqualToString:#"pushDetalhesView"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
// Pega o objeto da linha selecionada
ProgramacaoModel *object = [_programacao.programacaoArray objectAtIndex:indexPath.row];
// Pass the content from object to destinationViewController
[[segue destinationViewController] getProgramacao:object];
}
}
In my Details ViewController I create an iVar
#interface ProgramacaoDetalhesViewController ()
{
ProgramacaoModel *_programacao;
}
And set two method, one to receive the content and another to set the Labels
- (void) getProgramacao:(id)programacaoObject;
{
_programacao = programacaoObject;
}
- (void) setLabels
{
programacaoNomeLabel.text = _programacao.atracao;
}
Related
I know this question is asked many time , i had searched a lot and tried many solution but not worked. I have made a customize table view in which data is load from a service. The data load is quite limited , i have to show the detail of data into new view controller when user click on a cell. Its should pass data of the respective cell which carries data. I have tried segue technique to pass data to new vc but fails , its shows null in value which i'm passing. I have created some labels in new vc in which i'm calling the values from table view cell. My code is,
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"ShowDetail"]) {
//Do something
ShowViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
destViewController.tites = [_Title objectAtIndex:indexPath.row];
destViewController.prce = [_Price objectAtIndex:indexPath.row];
NSLog(#"PPPP is %#",destViewController.phon);
destViewController.ara = [_LandArea objectAtIndex:indexPath.row];
destViewController.phon = [_Phone objectAtIndex:indexPath.row];
destViewController.citi = [_City objectAtIndex:indexPath.row];
destViewController.loc = [_location objectAtIndex:indexPath.row];
destViewController.tye = [_type objectAtIndex:indexPath.row];
destViewController.Idss = [_Id objectAtIndex:indexPath.row];
destViewController.nam = [_name objectAtIndex:indexPath.row];
destViewController.emal = [_email objectAtIndex:indexPath.row];
destViewController.roomss = [_rooms objectAtIndex:indexPath.row];
destViewController.wash = [_washroom objectAtIndex:indexPath.row];
destViewController.flloors = [_floor objectAtIndex:indexPath.row];
destViewController.stat = [_status objectAtIndex:indexPath.row];
destViewController.descrp = [_descrip objectAtIndex:indexPath.row];
destViewController.countryy = [_country objectAtIndex:indexPath.row];
}
}
Issue in this question is that you are not populating the _Price and other arrays properly, so where you are populating _Title array , fill other arrays as well like _Price, _City
An outlet doesn't instantiate because an outlet is a variable (or property).
The objects in a nib are instantiated when that nib is loaded, and they are assigned to each outlet as immediately as possible afterward, after the objects are created but before awakeFromNib is sent to all relevant objects.
In your case you can pass data in ShowViewController and update the label in ShowViewController's viewDidLoad or viewDidAppear.
Define string in ShowViewController interface as
#property (strong, nonatomic) NSString * titesStr;
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"ShowDetail"]) {
//Do something
ShowViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
destViewController.titesStr = [_Title objectAtIndex:indexPath.row];
....
....
....
}
}
In ShowViewController viewDidAppear update your label as
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
tites.text = titesStr;
}
In place of passing data one by one you can use array also. Best implementation would be using model class.
EDIT
[self performSegueWithIdentifier:#"ShowDetail" sender:tableView];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"ShowDetail"]) {
//Do something
UITableView *tv = (UITableView*)sender;
ShowViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [tv indexPathForSelectedRow];
destViewController.tites = [_Title objectAtIndex:indexPath.row];
....
....
....
}
}
Make following changes in your code :
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"ShowDetail" sender:indexPath];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"ShowDetail"])
{
ShowViewController *destViewController =(ShowViewController *) segue.destinationViewController;
NSIndexPath *indexPath = (NSIndexPath *)sender;
destViewController.tites = [_Title objectAtIndex:indexPath.row];
destViewController.prce = [_Price objectAtIndex:indexPath.row];
// use this indexpath for segue
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
self.data= [self.nameList objectAtIndex:indexPath.row];
self.data= [self.rollList objectAtIndex:indexPath.row];
[self performSegueWithIdentifier:#"DetailVC" sender:self];
}
I've displayed student's name and roll number in custom cell. Now when i select one row i would like to pass those data to another UIViewController and display in labels. For I've one NSObject type file called 'Name' and i've one variable called 'data' which is of type 'Name'. Now here's my code in didSelectRowAtIndexPath where the nameList is overlapped by rollList which are stored on same variable self.data. if rollList line is removed then it works good. But when I store rollList in self.data it will overlap other.
Where, self.nameList is variable of type NSMutableArray which contains name of student and similarly, self.rollList contains student's roll.
Below is the code to pass data from segue. Here DetailVC is the destinationViewController, vc.data is the variable of type 'Name' and self.data is also the variable of same type.
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"DetailVC"]){
DetailVC *vc = (DetailVC *) segue.destinationViewController;
vc.data = self.data;
}
}
Overlapping is fundamental thing.
In your case your in NSObject type file (Name) you have to add two variable
NSNumber *rollNo;
NSString *name;
After that
-- UPDATE --
#interface TableVC : UIViewController {
Name *data;
}
-(void)viewDidLoad {
data = [[Name alloc] init]
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
self.data.name = [self.nameList objectAtIndex:indexPath.row];
self.data.rollNo = [self.rollList objectAtIndex:indexPath.row];
[self performSegueWithIdentifier:#"DetailVC" sender:self];
}
Then
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"DetailVC"]){
DetailVC *vc = (DetailVC *) segue.destinationViewController;
vc.data = self.data;
}
}
------ Detail VC ---
#property (nonatomic, strong) Name *data;
-(void)viewDidLoad {
self.labelRollNo.text = self.data.rollNo;
self.labelName.text = self.data.name;
}
try this way
#interface ViewController ()
{
NSString *name;
NSString *roll;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
name= [self.nameList objectAtIndex:indexPath.row];
roll= [self.rollList objectAtIndex:indexPath.row];
[self performSegueWithIdentifier:#"DetailVC" sender:self];
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"DetailVC"]){
DetailVC *vc = (DetailVC *) segue.destinationViewController;
vc.name = name;
vc.roll = roll;
}
}
you create two NSString name and roll properties in your DetailVC
DetailVC.h
#property (strong, nonatomic) NSString *name;
#property (strong, nonatomic) NSString *roll;
I have a tableView populated with NSString values from an NSFetchedResultsController. I have the cells configured to check/uncheck cells. That works perfectly.
I'm trying to configure the cells so clicking one of the labels within the cell triggers a segue to another view controller. I configured the label and threw a log statement in where I'd like to do the segue and everything works properly. When I add the segue, get no compiler errors, but it crashes at runtime with the follow error:
2015-05-31 08:09:04.656 MyApp[17682:1240919] -[UIViewController selectedItemPhoto:]: unrecognized selector sent to instance 0x7fa42b65d4e0
2015-05-31 08:09:04.694 MyApp[17682:1240919] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController selectedItemPhoto:]: unrecognized selector sent to instance 0x7fa42b65d4e0'
I'm fairly certain I'm doing something startlingly stupid, but I'm stumped as to what. I welcome suggestions.
MyCustomCell.h:
#property (strong, nonatomic) IBOutlet UILabel *itemDescription;
#property (strong, nonatomic) IBOutlet UILabel *itemGroup;
#property (strong, nonatomic) IBOutlet UIImageView *itemImage;
FirstVC.m methods:
cellForRowAtIndexPath method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// implement custom cell
MyCustomCell *customCell = [tableView dequeueReusableCellWithIdentifier:#"customCell" forIndexPath:indexPath];
// Get a hold of myManagedObject from FRC
MyNSManagedObject *myObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
// Configures 1st label to look like a hyperlink
customCell.itemDescription.text = myObject.itemDescription;
customCell.itemDescription.textColor = [UIColor blueColor];
customCell.itemDescription.userInteractionEnabled = YES;
// Enables gesture and sets demoObject to pass along via the segue called from labelTap
UITapGestureRecognizer *labelTapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:#selector(labelTap)];
[customCell.itemDescription addGestureRecognizer:labelTapGesture];
self.demoObject = myObject;
// Configures 2nd label within customCell
customCell.itemGroup.text = myObject.itemGroup;
// add image to cell, already imported into Images.xcassets
NSString *imageName = [NSString stringWithFormat:#"%#-1.jpg", myObject.photo];
customCell.imageView.image = [UIImage imageNamed:imageName];
// The following code ensures random checkmarks don't appear when the user scrolls.
if ([self.selectedObjects containsObject:[self.fetchedResultsController objectAtIndexPath:indexPath]]) {
customCell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
customCell.accessoryType = UITableViewCellAccessoryNone;
}
return customCell;
}
didSelectRowAtIndexPath method
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.selectedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
// Set the checkmark accessory for the selected row.
if ([tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryNone) {
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
[self.selectedObjects addObject:self.selectedObject];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
} else {
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone];
[self.selectedObjects removeObject:self.selectedObject];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
// Enables save button if there are items in the selectedObjects array
if (self.selectedObjects.count > 0) {
[self.saveButton setEnabled:YES];
} else {
[self.saveButton setEnabled:NO];
}
}
labelTap method
- (void) labelTap {
// The "hyperlink" effect I'm trying to achieve works without the segue
NSLog(#"itemDescription tapped");
[self performSegueWithIdentifier:#"mySegue" sender:nil];
}
prepareForSegue method
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:#"mySegue"] && self.demoObject != nil) {
// This line returns a value...
NSLog(#"self.demoObject = %#", self.demoObject.itemDescription);
// ...but it crashes here when it tries to set on the destinationViewController
SecondViewController *destinationViewController = [segue destinationViewController];
destinationViewController.selectedItemPhoto = self.demoObject.photo;
destinationViewController.selectedItemTitle = self.demoObject.itemDescription;
}
}
SecondViewController.h properties
// The photo is a string that references a filename in my app
#property (nonatomic, strong) NSString *selectedItemPhoto;
#property (nonatomic, strong) NSString *selectedItemTitle;
From the error it seems you did not set the class of your second view controller. It seems it is UIViewController and should be SecondViewController.
In your storyboard select the second view controller and set its class to SecondViewController.
Another advice is that in Objective C you should use introspection before casting an object. So in your code I would add:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:#"mySegue"] && self.demoObject != nil) {
// This line returns a value...
NSLog(#"self.demoObject = %#", self.demoObject.itemDescription);
// ...but it crashes here when it tries to set on the destinationViewController
if ([[segue destinationViewController] isKindOfClass:[SecondViewController class]]) {
SecondViewController *destinationViewController = (SecondViewController *)[segue destinationViewController];
destinationViewController.selectedItemPhoto = self.demoObject.photo;
destinationViewController.selectedItemTitle = self.demoObject.itemDescription;
}
}
}
In this way the segue won't happen but the app won't crash.
I figured it out! I had three issues (two were tied together):
Issue 1: Juan Catalan pointed out I didn't have my storyboard set for SecondViewController
Issue 2: Yuchen & luk2302 raised the issue of how I'm performing the segue.
Issue 3: I don't need prepareForSegue
Here's what I did:
1: I removed prepareForSegue.
2: I removed the storyboard segue.
2: I altered labelTap method to add a parameter for the labelTapGesture
- (void) labelTap:(UITapGestureRecognizer *)sender {
NSLog(#"stretchDescription tapped");
CGPoint location = [sender locationInView:self.view];
if (CGRectContainsPoint([self.view convertRect:self.tableView.frame fromView:self.tableView.superview], location)) {
CGPoint locationInTableview = [self.tableView convertPoint:location fromCoordinateSpace:self.view];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:locationInTableview];
if (indexPath) {
self.demoObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
DisplayStretchViewController *destinationViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"SecondVC"];
// Set properties on destinationVC
destinationViewController.itemPhoto = self.demoObject.photo;
destinationViewController.itemTitle = self.demoObject.stretchDescription;
[self.navigationController pushViewController:destinationViewController animated:YES];
}
}
}
I also found this post extremely helpful:
UILabel with Gesture Recognizer inside UITableViewCell blocks didSelectRowAtIndexPath
Thank you to all for your input!
I am new to programming and am probably hung up on a simple problem. I am using parse for my array in my tableview. When the row is selected i want to segue to a search bar on another view controller. The segue works fine and the tableview works fine but i can't seem to get the objectId to pass.
#import "bookmarkViewController.h"
#import "Parse/Parse.h"
#import <ParseUI/ParseUI.h>
#import "ViewController.h"
#implementation bookmarkViewController
#synthesize postArray;
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self
action:#selector(refreshButtonHandler:)]];
}
- (void)viewWillAppear:(BOOL)animated
{
if ([PFUser currentUser])
[self refreshButtonHandler:nil];
}
#pragma mark - Button handlers
- (void)refreshButtonHandler:(id)sender
{
//Create query for all Post object by the current user
PFQuery *postQuery = [PFQuery queryWithClassName:#"Post"];
[postQuery whereKey:#"author" equalTo:[PFUser currentUser]];
// Run the query
[postQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
//Save results and update the table
postArray = objects;
[self.tableView reloadData];
}
}];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
(NSInteger)section
{
// Return the number of rows in the section.
return postArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
// Configure the cell with the textContent of the Post as the cell's text label
PFObject *post = [postArray objectAtIndex:indexPath.row];
[cell.textLabel setText:[post objectForKey:#"textContent"]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
*)indexPath{
NSLog(#"cell tapped");
PFObject *post = [postArray objectAtIndex:indexPath.row];
NSLog(#"%#", post.objectId);
[self performSegueWithIdentifier:#"searchBookmark" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
ViewController *vc = [segue destinationViewController];
vc.labelText = post.objectId;
}
}
#end
at vc.label.text i always get use of undeclared identifier "post" but i can't seem to figure out how to get it recognized. It is in the above method.
the NSLogs reply correctly 16:17:27.513 [App] cell tapped
[App] cgdVY7Eu9h
Change your didSelectRowAtIndexPath and prepareForSegue to this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath* )indexPath{
[self performSegueWithIdentifier:#"searchBookmark" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSLog(#"cell tapped");
PFObject *post = [postArray objectAtIndex:indexPath.row];
NSLog(#"%#", post.objectId);
ViewController *vc = [segue destinationViewController];
vc.labelText = post.objectId;
}
}
Post is a local variable that you created inside didSelectRowAtIndexPath, so it can't be used outside that method. The easy way to fix this, is to pass post as the sender argument in performSegueWithIdentifier:sender:. You can pass any object you want as the sender.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
NSLog(#"cell tapped");
PFObject *post = [postArray objectAtIndex:indexPath.row];
NSLog(#"%#", post.objectId);
[self performSegueWithIdentifier:#"searchBookmark" sender:post];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
PFObject *post = (PFObject *)sender;
ViewController *vc = [segue destinationViewController];
vc.labelText = post.objectId;
}
UIViewController -> segue -> UITableViewController
I had one problem that i solved with answer -1- Thanks.
So i had a kind of UIViewController and i wanted with button just segue to another UITableViewController and i noticed that it stacked and was frozen. I could not scroll my Table ...
My Code was :
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
MasterViewController *controller =segue.destinationViewController;
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:controller animated:YES completion:nil];
}
My CPU was over 100% overloaded.
So the answer number 1 worked for me well. New Code is then :
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
MasterViewController *vc = [segue destinationViewController];
}
and the table with 30 entries works now just like a charm =)
I am just trying to transfer a simple string from a UILabel in a prototype cell into a label in the next View Controller. Value of label.text in the viewDidLoad of the View Controller is returning (null).
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
mainCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (mainCell == nil) {
mainCell = [[dictionaryTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSString* date = [dateArray objectAtIndex:indexPath.row];
mainCell.viewLabel.text = date;
return mainCell;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"View Segue"]) {
NSLog(#"View Load Segue Success");
ViewController *one = segue.destinationViewController;
one.label.text = mainCell.viewLabel.text;
}
}
What am I doing wrong here?
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"View Segue"]) {
NSLog(#"View Load Segue Success");
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
ViewController *one = segue.destinationViewController;
one.label.text = [dateArray objectAtIndex:indexPath.row];
}
}
And actually, assigning text to text label you should do in your viewController one's method(viewDidLoad or viewWillAppear). So, you need to make a property in viewController one for transferring NSString.
You can use indexPathForSelectedRow:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"View Segue"]) {
ViewController *one = segue.destinationViewController;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
one.textProperty = [dateArray objectAtIndex:indexPath.row];
}
}
Or you can also use sender if your segue is from the cell to the next scene, e.g.:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"View Segue"])
{
ViewController *one = segue.destinationViewController;
NSAssert([sender isKindOfClass:[UITableViewCell class]], #"Not cell");
UITableViewCell *cell = sender;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
one.textProperty = [dateArray objectAtIndex:indexPath.row];
}
}
Two things to note:
As a matter of good programming style, I am not retrieving the text value from the cell. I'm retrieving the text value from the model. You should not be relying upon the view for information to be passed along. Go back to the model, the original source of the information.
Do not set the text property of the label in the destination controller directly. The controls of the destinationController have not been created yet. You should defer setting controls until the destinationController's viewDidLoad. So, instead, create a NSString property in the destination controller:
#property (nonatomic, strong) NSString *textProperty;
Clearly, you should use a more descriptive name than textProperty, but hopefully you get the idea. Anyway, prepareForSegue can set this new property and the viewDidLoad of the destination controller should then use that NSString property to populate the text property of the UILabel, e.g.:
- (void)viewDidLoad
{
[super viewDidLoad];
self.label.text = self.textProperty;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
YourViewController *controller =[[YourViewController alloc] init];
[self presentModalViewController:controller animated:YES];
one.label.text = [dateArray objectAtIndex:indexPath.row];
}
Change the label.text after presentModalViewController. Now what happens?
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion
I understand you are already using Segue. You should follow the other answer.