0
我試圖連接表格視圖中的每個單元格必須在網絡視圖中與不同的網頁連接,並且我還使用了導航控制器。表格視圖中的每個單元格都必須連接到IOS中的不同網頁
這是maincontroller.m文件
`-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.settle count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *simpletableidentifier = @"tcell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpletableidentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpletableidentifier];
}
cell.textLabel.text = [settle objectAtIndex:indexPath.row];
return cell;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"show"]) {
NSIndexPath *indexPath=self.tableView.indexPathForSelectedRow;
website *destViewController = segue.destinationViewController;
destViewController.web = [settle objectAtIndex:indexPath.row];
switch (indexPath.row) {
case 0:
[email protected]"http//www.google.com";
break;
case 1:
[email protected]"http//www.yahoo.com";
break;
default:
break;
}
}
`
,並在另一個視圖控制器文件中所有的
@implementation website
@synthesize web;
@synthesize u;
//@synthesize recipeLabel;
//@synthesize recipeName;
- (void)viewDidLoad
{
[super viewDidLoad];
// Add code to load web content in UIWebView
{
NSURL *url = [NSURL URLWithString:@"u"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[web loadRequest:request];
}