【发布时间】:2014-08-24 04:32:41
【问题描述】:
我是 iOS 及其开发的新手。我正在开发 iPhone 应用程序。我有 UITableView 和 UIWebView。当我按下 UITableview 的单元格时,点击那里我想在我的 UIWebView 中加载各种网页。请在下面找到我遇到的错误。
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 吗?你有一个名为 DeatailViewController 的 xib 文件吗?
-
@ali59a 我正在使用storyboard。我没有这样的文件
-
你的故事板中是否有一个带有 DeatailViewController 类的视图控制器?
-
太棒了。如果您使用情节提要,则不应使用 initWithNib。您可以直接在情节提要中使用 segue 将表格视图的单元格关联到详细视图控制器,或者您可以在情节提要中为您的详细视图控制器提供标识符并进行以下操作: DetailViewController *temp = [[UIStoryboard storyboardWithName:@"Name你的故事板“捆绑:nil] instantiateViewControllerWithIdentifier:@"Identifier of Detail VC"];
-
如果你在storyboard中使用,你不能使用加载nib文件,它总是显示错误,你需要用标识符名称或特定VC名称的故事板名称来识别,使用这个链接@ 987654321@
标签: ios iphone objective-c uitableview uiwebview