1
votes

I have a ViewController embedded in a NavigationController. The ViewController has a UIWebView that I'm trying to capture links from. I'm able to intercept the links, but when I try to push the link content to a detail page, it seems to be firing a new Controller but it's invisible. If I click a link for a second time (or if I just click a second link) I see a back button pop up, but again the actual content of the new ViewController is not visible.

Here is the log output for the first link click:

2011-11-07 10:38:27.526 WGGB[43875:f803] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate:   <NSInternalInconsistencyException> Could not load NIB in bundle: 'NSBundle  </Users/sonnyjitsu/Library/Application Support/iPhone Simulator/5.0/Applications/4B3D5152-4EA5-4C84-BB22-A774FCB8B6A7/WGGB.app> (loaded)' with name 'Detail View'

As you can see, it's "loading" the new view, but I see nothing in the simulator. Then the second time I click the same link (or click a new link) I see this in the log:

2011-11-07 10:38:30.605 WGGB[43875:f803] url is http://www.blahblahblah.com/mobile

The method in question is this:

-(BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{

    NSURL *url = request.URL;
    NSString *urlString = url.absoluteString;
    NSRange page = [ urlString rangeOfString: @"/mobile" ];
    if (page.location == NSNotFound) {

        SingleStoryViewController *detailViewController = [[SingleStoryViewController alloc] initWithNibName:@"Detail View" bundle:nil];
        NSString *requestURL = 
            [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
        [detailViewController.webView loadRequest:
            [NSURLRequest requestWithURL:[NSURL URLWithString:requestURL]]];
        [self.navigationController pushViewController:detailViewController animated:YES];

        NSLog(@"url is %@", url);
        return NO;
    } else {
        return YES;
    }
}

Top of my SingleStoryViewController.m

#import "SingleStoryViewController.h"

@implementation SingleStoryViewController

@synthesize webView;

Entire SingleStoryViewController.h #import

@interface SingleStoryViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

Here is a link to an image of my Xcode storyboard, for what it's worth: http://i.imgur.com/I653v.png

I've been working on this for a good 14 to 16 hours now and I'm finally saying 'uncle' and asking for help. Any help would be appreciated, I'm very new to iOS programming so I apologize if there is something really stupid I'm missing.

1

1 Answers

1
votes

As you can see, it's "loading" the new view...

That's not what the error says. The error says this:

Could not load NIB in bundle: [...] with name 'Detail View'

I'd start by checking the name of the .xib file in your app -- it sounds like it may not match the name you're using in the code.

Update: Per comments below, it turns out that this is app uses storyboards and doesn't contain any .xib files, so it's no surprise that attempting to load a view controller from a .xib produces an error. The correct way to load a view controller from a storyboard, when necessary, is to use UIStoryboard's -instantiateViewControllerWithIdentifier: method instead of UIViewController's -initWithNibName:bundle:.