Reputation: 1150
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
Upvotes: 0
Views: 1635
Reputation: 4277
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 :
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)
Upvotes: 2
Reputation: 451
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];
}
}
Upvotes: 1