0

I'm new to iOS and its developing. I'm developing iPhone application.there i have UITableView and UIWebView. When i am pressing UITableview's cell, according to click there i want to load various webpages in my UIWebView. please find below the Errors i've got.

    2014-07-05 08:25:59.319 WADTourisum[432:60b] myUrl-->2 
2014-07-05 08:26:02.753 WADTourisum[432:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main.storyboard' in bundle NSBundle </Users/venushka/Library/Application Support/iPhone Simulator/7.1/Applications/3325DB09-FC4D-4B28-8DAF-5F9ABCAB8464/WADTourisum.app> (loaded)'
*** First throw call stack:
(
    0   CoreFoundation                      0x01a421e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0158f8e5 objc_exception_throw + 44
    2   UIKit                               0x007b3400 -[UIStoryboard name] + 0
    3   WADTourisum                         0x0001411e -[Essentialinfocontroller tableView:didSelectRowAtIndexPath:] + 174
    4   UIKit                               0x003399a1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1513
    5   UIKit                               0x00339b14 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 279
    6   UIKit                               0x0033e10e __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
    7   UIKit                               0x0026d0aa ___afterCACommitHandler_block_invoke + 15
    8   UIKit                               0x0026d055 _applyBlockToCFArrayCopiedToStack + 403
    9   UIKit                               0x0026ce76 _afterCACommitHandler + 532
    10  CoreFoundation                      0x01a0a36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    11  CoreFoundation                      0x01a0a2bf __CFRunLoopDoObservers + 399
    12  CoreFoundation                      0x019e8254 __CFRunLoopRun + 1076
    13  CoreFoundation                      0x019e79d3 CFRunLoopRunSpecific + 467
    14  CoreFoundation                      0x019e77eb CFRunLoopRunInMode + 123
    15  GraphicsServices                    0x03a365ee GSEventRunModal + 192
    16  GraphicsServices                    0x03a3642b GSEventRun + 104
    17  UIKit                               0x0024ff9b UIApplicationMain + 1225
    18  WADTourisum                         0x00004d1d main + 141
    19  libdyld.dylib                       0x02089701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Essentialinfocontroller.m

    #import "Essentialinfocontroller.h"

        @interface Essentialinfocontroller ()
        @end

        @implementation Essentialinfocontroller

        @synthesize myWebview;

        @synthesize courses;//dictionary type object
        @synthesize coursekeys; //array type object



        - (void)viewDidLoad
        {
            [super viewDidLoad];
            NSString *myfile= [[NSBundle mainBundle]pathForResource:@"essentialinfo" ofType:@"plist"];

           // NSLog(@"testing path %@",myfile);

            courses=[[NSDictionary alloc]initWithContentsOfFile:myfile];

            coursekeys =[courses allKeys];

        }

        - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
        {
            return [courses count];
        }


        - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        {
            UITableViewCell * cell=[[ UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];

            NSString * currentCourseName =[coursekeys objectAtIndex:[indexPath row]];

            [[cell textLabel]setText:currentCourseName];

            cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;

            return  cell;
        }

        //implement stack method

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



            if(indexPath.row==0){


        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main.storyboard" bundle:nil];

        UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"story"];

        [self.navigationController pushViewController:viewController animated:YES];


    }
    if (indexPath.row==1) {
        NSLog(@"myUrl-->2 ");

    }


        }

    //end




    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];

    }

@end

DetailViewController.m

@implementation DetailViewController

@synthesize info;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *url= [NSURL URLWithString:@"http://www.google.lk"];
    NSURLRequest * requestURL= [NSURLRequest requestWithURL:url];
    [info loadRequest:requestURL];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];

}

@end

StoryBoard

VenushkaT
  • 1,152
  • 2
  • 19
  • 42
  • Are you using Storyboard ? Do you have a xib file called DeatailViewController ? – Ali Abbas Jul 03 '14 at 07:11
  • @ali59a im using storyboard.i dont have such a file – VenushkaT Jul 03 '14 at 07:12
  • Do you have a View Controller in your storyboard with a DeatailViewController class ? – Ali Abbas Jul 03 '14 at 07:14
  • Great. If you are using storyboard, you shouldn't use initWithNib. You can use segue directly in your storyboard to associate the cell of your table view to your detail view controller OR you can give an identifier to your Detail View Controller in storyboard and make this : DetailViewController *temp = [[UIStoryboard storyboardWithName:@"Name Of your Storyboard" bundle:nil] instantiateViewControllerWithIdentifier:@"Identifier of Detail V C"]; – Ali Abbas Jul 03 '14 at 07:19
  • if u r used in storyboard, u can't use the load nib file , it alway s showing error, u need to identify with identifier name or storyboard name of the particular VC name, use this link http://stackoverflow.com/questions/23102978/swrevealviewcontroller-without-using-navigationcontroller/23105142#23105142 – Anbu.Karthik Jul 03 '14 at 07:22

2 Answers2

2

This line raise the exception :

DetailViewController *temp =[[DetailViewController alloc]initWithNibName:@"DeatailViewController" bundle:[NSBundle mainBundle]];

The line above initialise a view controller with a nib file(.xib)

As you say in your comment, you are using storyboard so you should use UIStoryboard Class

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil];

UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController identifier"];

Now, to get the identifier of your view controller :

  1. Open your storyboard
  2. Click on your view controller (Detail view controller here)
  3. On the right side : Utilities, click on show the identity inspector (third button)
  4. In the storyboard ID field, put the identifier (DetailViewController identifier for example)

Edit :

I think that the name of your storyboard is wrong. In your project you have a file called Main.storyboard or somethingElse.storyboard, so you should replace storyboard in this line :

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"storyboard" bundle:nil]; by Main or somethingElse without the .storyboard extension

Then you replace DetailViewController identifier in this line UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController identifier"]; by the identifier of your view controller (story in your screenshot)

Community
  • 1
  • 1
Ali Abbas
  • 4,247
  • 1
  • 22
  • 40
  • thank for you advance. now i've got my Error but problem is when come to if(indexPath.row==0){ } // code section the desired DetailView controller isn't navigate as it is.how can i fix it.i think i'm having problem with get a id and story board's -> ViewController's UIWebview – VenushkaT Jul 04 '14 at 14:11
  • can you update your post please with the new code's version ? – Ali Abbas Jul 04 '14 at 14:20
  • could you please find my Edited one.still i couldn't solve story board matter.thank you for you advance so far. – VenushkaT Jul 05 '14 at 03:05
  • You should put Main and not Main.storyboard in this line : UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main.storyboard" bundle:nil]; – Ali Abbas Jul 05 '14 at 15:19
  • AB thank you for your Advance it works me. i have accepted your Answer with previous my vote.thank you very much (Y) – VenushkaT Jul 05 '14 at 16:19
1
DetailViewController

@property(nonatomic,retain)NSString *myurl;



- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *url= [NSURL URLWithString:myurl];
    NSURLRequest * requestURL= [NSURLRequest requestWithURL:url];
    [info loadRequest:requestURL];

}


Essentialinfocontroller

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

if(indexPath.row==0){ //what ever you want row 


     DetailViewController *temp =[[DetailViewController alloc]initWithNibName:@"DeatailViewController" bundle:nil];

     //or [[DetailViewController alloc]init];


     temp.myurl = @"http://www.google.lk";

      [self.navigationController pushViewController:temp  animated:YES];

}


}