I have two View Controllers: MainScreenViewController
and TargetScreenViewController
;
In MainScreenViewController
I have UITableView
with custom cells, in TargetScreenViewController
I have the label which i need change.
I need to get some value, index path for example, and pass it along to TargetScreenViewController
and change the label based on that value.
I already setup the push segue in Triggered Segues in cell, but how can i pass some value and get it there?
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
TargetView *target = [[TargetView alloc]initWithNibName:@"TargetView" bundle:nil];
NSString *data = @"Success";
target.incomingData = data;
}
in TargetView:
- (void)viewDidLoad
{
[super viewDidLoad];
self.mLabel.text = self.incomingData;
}
but label is blank =[
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
Class *yourObject=[self.arr objectAtIndex:indexPath.row];
TargetView *vc=[[TargetView alloc] initWithNibName:@"TargetView" bundle:nil];
vc.object=yourObject; //Create a p
[self.navigationController pushViewController:vc animated:YES];
}
In your TargetView
-(void)viewDidLoad{
self.lbl.text=self.object.value;
}
You can make a notification and post notification with a object. The object what you need to send to second Controller.
try this .....
1.create a property in your target view controller .
2.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
targetviewcontroller * obj = create object here .
obj.property = dataToBeSent ;
---------------
}
then you will get your data by accessing property
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.