0

My viewcontroller is using UITableView and i want to go to detialView by clicking on the row. Using the didSelectRowAtIndexPath.

I am working on storyboard but my UITableView class is not using Scene on stroyborad it made programatically and other class with is detailView with is a scene on the Storyboard.

But i’m unable to show my detailView , Trying so many ideas. In this i’m unable to use segue because UItableview Class is not a scene it made programtically and the other way to display detialViewController is using didSelectRowAtIndexPath.

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

    ServiceDisplayViewController *serviceDisplayViewController =
    [self.storyboard instantiateViewControllerWithIdentifier:@"serviceDisplayViewController"];

    [self presentViewController:serviceDisplayViewController animated:NO completion:nil];


}

But it gives me error.

Application tried to present a nil modal view controller on target <SegmentsViewController: 0xa8757e0>.'

Can anyone please suggest me the best way to resolve this issue.

Thanks In Advance.

user2767343
  • 173
  • 1
  • 3
  • 12

3 Answers3

0
ServiceDisplayViewController *serviceDisplayViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"ServiceDisplayViewController"];
Your Identifier should be your class name not object name
amit soni
  • 2,183
  • 1
  • 14
  • 17
  • sory again the same error. 'Application tried to present a nil modal view controller on target .' – user2760176 Dec 23 '13 at 07:42
  • Please don't simply post the code. Give some explanation or information or usage about your code. For example, see [this answer](http://stackoverflow.com/a/16893057/756941). – Nazik Dec 23 '13 at 07:51
0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //This is the line where your error is
    ServiceDisplayViewController *serviceDisplayViewController =
    [self.storyboard instantiateViewControllerWithIdentifier:@"serviceDisplayViewController"];
    //serviceDisplayViewController object does not get the correct object.
   // In the storyboard check whether the identifier name(serviceDisplayViewController) is correct or not. Check even for case-sensitive error
   //Also check self.storyboard object is also not nil



    [self presentViewController:serviceDisplayViewController animated:NO completion:nil];


}

enter image description here

ipraba
  • 16,485
  • 4
  • 59
  • 58
0

First make sure the identifiers are correct. then write the below code

UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"myStoryBoardName" bundle:nil];

if (mystoryboard != nil)
{
  ServiceDisplayViewController *serviceDisplayViewController = [mystoryboard instantiateViewControllerWithIdentifier:@"ServiceDisplayViewController"];

    if(serviceDisplayViewController != nil)
    {
      [self presentViewController:serviceDisplayViewController animated:NO completion:nil];
    }
    else
    {
       NSLog(@"%@", serviceDisplayViewController is returning as nil);
    }
}
else
{
   NSLog(@"%@", mystoryboard is returning as nil);  
}
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102