Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Passing Data between UITableViewCell to UIViewController without segue

In tableView i try to use that method it worked but the viewcontroller returned a black screen with the push back on top

     Pageviewcontroller=[[PAgeViewController alloc]init];
     [self.navigationController pushViewController:Pageviewcontroller animated:NO];

3 Answers

This is literally what the prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender method was made for. Just override it and do what you want. You can read all about it in the UIViewController Class Reference

no I am not using segue

It is worth mentioning if you want to pass data from ViewController A to ViewController B. prepareForSegue is the right choice (like Michael Hulet says, if you're using storyboards. If not, just override the

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

However if you want to pass data from ViewController B to ViewController A, the have a look at either delegates, notifications or blocks. Personally, I'd recommend the delegate pattern :)

I am using tableView i try to use that method it worked but the viewcontroller return a black screen with the push back on top

     Pageviewcontroller=[[PAgeViewController alloc]init];
     [self.navigationController pushViewController:Pageviewcontroller animated:NO];

Could you share the project through dropbox and we'll have a look? :)