我是iOS及其开发人员的新手。我正在开发iPhone应用程序。我有UITableView和UIWebView。当我按下UITableview的单元格时,根据点击那里我想在我的UIWebView中加载各种网页。因为我必须从EssentialViewController.there传递字符串链接到DeatailViewController我得到Errors.please帮助我。
错误记录
2014-07-07 07:09:53.511 WADTourisum[564:60b] -[UINavigationController currentActiveNVC]: unrecognized selector sent to instance 0x8e9b650
2014-07-07 07:09:53.514 WADTourisum[564:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController currentActiveNVC]: unrecognized selector sent to instance 0x8e9b650'
*** First throw call stack:
(
0 CoreFoundation 0x01a421e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0158f8e5 objc_exception_throw + 44
2 CoreFoundation 0x01adf243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01a3250b ___forwarding___ + 1019
4 CoreFoundation 0x01a320ee _CF_forwarding_prep_0 + 14
5 WADTourisum 0x00002c9b -[AMSlideMenuContentSegue perform] + 171
6 UIKit 0x007b3f0c -[UIStoryboardSegueTemplate _perform:] + 174
7 UIKit 0x0037041c -[UIViewController performSegueWithIdentifier:sender:] + 72
8 WADTourisum 0x00013b03 -[Essentialinfocontroller tableView:didSelectRowAtIndexPath:] + 179
9 UIKit 0x003399a1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1513
10 UIKit 0x00339b14 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 279
11 UIKit 0x0033e10e __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
12 UIKit 0x0026d0aa ___afterCACommitHandler_block_invoke + 15
13 UIKit 0x0026d055 _applyBlockToCFArrayCopiedToStack + 403
14 UIKit 0x0026ce76 _afterCACommitHandler + 532
15 CoreFoundation 0x01a0a36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
16 CoreFoundation 0x01a0a2bf __CFRunLoopDoObservers + 399
17 CoreFoundation 0x019e8254 __CFRunLoopRun + 1076
18 CoreFoundation 0x019e79d3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x019e77eb CFRunLoopRunInMode + 123
20 GraphicsServices 0x03a365ee GSEventRunModal + 192
21 GraphicsServices 0x03a3642b GSEventRun + 104
22 UIKit 0x0024ff9b UIApplicationMain + 1225
23 WADTourisum 0x000046fd main + 141
24 libdyld.dylib 0x02089701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
EssetialViewController.h
import <UIKit/UIKit.h>
#import "DetailViewController.h"
@interface Essentialinfocontroller : UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *info;
@property (nonatomic,strong) NSDictionary * courses;
@property (nonatomic, strong)NSArray *coursekeys;
@property (nonatomic,retain)IBOutlet DetailViewController * myWebview;
@property(nonatomic,strong) NSString* customeLink;
@end
EssetialViewController.m
#import "Essentialinfocontroller.h"
@interface Essentialinfocontroller ()
@end
@implementation Essentialinfocontroller
@synthesize myWebview;
@synthesize courses;//dictionary type object
@synthesize coursekeys; //array type object
@synthesize customeLink;
- (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){
[self performSegueWithIdentifier:@"segue" sender:self];//**Error is here**
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"story"];
customeLink=@"https://www.facebook.com/";
[self.navigationController pushViewController:viewController animated:YES];
}
if (indexPath.row==1) {
NSLog(@"myUrl-->2 ");
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"segue"])
{
DetailViewController *vc = [segue destinationViewController];
vc.link=customeLink;
}
}
//end
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
DetailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *info;
@property(strong,nonatomic)NSString * link;
@end
DetailViewController.m
#import "DetailViewController.h"
@interface DetailViewController ()
@property(nonatomic,weak)NSString *customelink;
@end
@implementation DetailViewController
@synthesize info;
@synthesize link;
@synthesize customelink;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.customelink=self.link;
NSLog(@"link--> %@",self.customelink);
NSURL *url= [NSURL URLWithString:customelink];
NSURLRequest * requestURL= [NSURLRequest requestWithURL:url];
[info loadRequest:requestURL];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
答案 0 :(得分:1)
<强> didSelectRowAtIndexPath方法强>
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row==0)
{
[self performSegueWithIdentifier:@"segue" sender:self];
}
}
<强> prepareForSegue 强>
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"segue"])
{
DetailViewController *vc = [segue destinationViewController];
vc.link=@"https://www.facebook.com/";
}
}