0

I have a app with UITableView (in PatientViewController) and every click on different cells should send different values to the ArticleViewController. I made every transition between ViewControllers with this code:

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
NewsViewController *mv = (NewsViewController*)[mainStoryboard instantiateViewControllerWithIdentifier:@"news"];
[self presentViewController:mv animated:YES completion:NULL];

I didn't want to use NavigationController and don't want to use Storyboard to create segue. So how can I do it with only writing code, without using Storyboard? Thank you.

Akhilrajtr
  • 5,170
  • 3
  • 19
  • 30
Arda Oğul Üçpınar
  • 881
  • 1
  • 14
  • 38
  • What container you are using ? Do you want to have custom animations or UINavigationController style ? – Grzegorz Krukowski Jan 27 '14 at 09:52
  • I have a UIViewController extending UITableViewDelegate and UITableViewDataSource. It has a tableview and a custom cell named "Cell". Animations and NavController are not my concern. As you know we are doing right-click-drag from the button to the other view controller to create a segue on Storyboard. **I don't want it** All I want to do is create a segue on tableviewcell click, without using StoryBoard just with coding. – Arda Oğul Üçpınar Jan 27 '14 at 09:57

3 Answers3

1

You can create a UIStoryBoardSegue with the following :

  UIStoryboardSegue :: initWithIdentifier:source:destination:

and then, from the source UIViewController, can call the following:

 performSegueWithIdentifier:sender:

For details, refer to Overview section of UIStoryBoardSegue documentation.

jacquard
  • 1,307
  • 1
  • 11
  • 16
0

Try this:

 NewsViewController *nVC = [self.storyboard instantiateViewControllerWithIdentifier:@"news"];
[self presentViewController:nVC animated:YES completion:NULL];
Ashutosh
  • 2,215
  • 14
  • 27
0

If you don't want to make any view controller through Storyboard, make a view controller with XIB. then, call the following method to init an instance.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil; 

When a cell is selected, you can use the following method to present a view controller that you want to show.

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion
Kyokook Hwang
  • 2,682
  • 21
  • 36