UIWebVIew中的UITableView未加载UIWebVIew。它需要IBAction吗?

UIWebVIew中的UITableView未加载UIWebVIew。它需要IBAction吗?,uitableview,uiwebview,Uitableview,Uiwebview,这是我到目前为止得到的代码,基本上应该发生的是,一旦你在UITableView中进行选择,你应该会得到一个转换,它将把你带到UIWebView上,尽管所发生的一切是一旦你进行了选择,它只会高亮显示蓝色 第一视图控制器.h 网站视图控制器.h 您需要一个IB操作或一个到网站视图控制器的序列(对于静态单元格)。当涉及到动态原型时,segues将起作用。你可以用一点代码来完成这些步骤。首先,转到情节提要并控制从第一个视图控制器到网站视图控制器的拖动(使用底部的图标或使用文档大纲)。然后,在给segue

这是我到目前为止得到的代码,基本上应该发生的是,一旦你在UITableView中进行选择,你应该会得到一个转换,它将把你带到UIWebView上,尽管所发生的一切是一旦你进行了选择,它只会高亮显示蓝色

第一视图控制器.h

网站视图控制器.h


您需要一个IB操作或一个到网站视图控制器的序列(对于静态单元格)。当涉及到动态原型时,segues将起作用。你可以用一点代码来完成这些步骤。首先,转到情节提要并控制从第一个视图控制器到网站视图控制器的拖动(使用底部的图标或使用文档大纲)。然后,在给segue一个标识符后,使用以下代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"yourSegueIdentifier" sender:[self.tableView cellForRowAtIndexPath:indexPath]];
}
编辑2:如果使用xib,请执行此操作(无控制拖动):


我没有使用情节串连板,我使用的是.xib只能使用以下内容:
[self-presentModalViewController:otherViewCon动画:是]
您不能使用它,因为iOS 6中不推荐使用
presentmodalviewcontroller animated
,当我添加该行时,它以红色显示,您也不希望我控制拖动,是吗?不幸的是,没有修复,我现在得到一个错误,读到“UINavigationController”的
无可见@interface声明选择器“pushViewController:animated:sender
,不幸的是,这就是我得到的全部。我通常不使用XIB,因此我无法进一步帮助您。很抱歉。您的表视图控制器是否在导航控制器内?在didSelectRowAtIndexPath中设置断点并检查self.navigationController的值。我打赌是零。
#import "YoMaFifthViewController.h"
#import "YoMaWebsiteViewController.h"

@interface YoMaFifthViewController ()

@end

@implementation YoMaFifthViewController



- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
    // Custom initialization
}
return self;

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.

}

#pragma mark - view lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];

data = [NSArray arrayWithObjects:@"Website", @"Developer", nil];
sites = [NSArray arrayWithObjects:
         @"https://www.google.co.uk/",
         @"https://www.google.co.uk/",
         nil];


// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

// Return the number of rows in the section.
return [data count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

// Configure the cell...

cell.textLabel.text = [data objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [sites objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:[data objectAtIndex:indexPath.row]];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;





}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:      (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
    // Delete the row from the data source
    [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}   
else if (editingStyle == UITableViewCellEditingStyleInsert) {
    // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/

#pragma mark - Table view delegate

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

{
YoMaWebsiteViewController *wvc = [[YoMaWebsiteViewController alloc] initWithNibName:@"YoMaWebsiteViewController" bundle:nil];
wvc.site = [sites objectAtIndex:indexPath.row];
[self.navigationController pushViewController:wvc animated:YES];

}




@end
#import <UIKit/UIKit.h>

@interface YoMaWebsiteViewController : UIViewController
{

IBOutlet UIWebView *webview;

}

@property (retain) NSString *site;


@end
#import "YoMaWebsiteViewController.h"

@interface YoMaWebsiteViewController ()

@end

@implementation YoMaWebsiteViewController
@synthesize site;

- (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:self.site];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];

// Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"yourSegueIdentifier" sender:[self.tableView cellForRowAtIndexPath:indexPath]];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.navigationController pushViewController:viewControllerNameHere animated:YES sender:[self.tableView cellForRowAtIndexPath:indexPath]];
}