UITableView
创建的名字列表,当有人选择一行时,它会打开相对网址,但是当加载网页时会出现问题
网页上有“UITableView”等行。
你知道为什么会产生这种错误吗?
这就是它产生的东西;
更新 我已经重新写了我的应用程序,但问题仍然存在,我不明白为什么在网页上显示行
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSDictionary *Game = [[self.Sections valueForKey:[[[self.Sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
[tableView deselectRowAtIndexPath:indexPath animated:YES]; //svanisce il blu
NSLog(@"%@", [[self.Games objectAtIndex:indexPath.row ] objectForKey:@"Url"]); // funge
WebPage *newWeb = [[WebPage alloc] init];
newWeb.theUrl = [NSURL URLWithString:[Game objectForKey:@"Url"]];
[self.navigationController pushViewController:newWeb animated:YES];
}
即WebPage.h
#import <UIKit/UIKit.h>
@interface WebPage : UITableViewController <UIWebViewDelegate> {
UIWebView *webView;
NSURL *theUrl;
}
@property (nonatomic, retain) NSURL *theUrl;
@property (nonatomic, retain) UIWebView *webView;
@end
那就是WebPage.m
#import "WebPage.h"
@implementation WebPage
@synthesize theUrl;
@synthesize webView;
- (void)viewDidLoad
{
[super viewDidLoad];
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0, self.view.bounds.size.width, self.view.bounds.size.height)];
webView.delegate = self;
webView.scalesPageToFit = YES;
[webView loadRequest:[NSURLRequest requestWithURL:theUrl]];
[self.view addSubview:webView];
}
@end
答案 0 :(得分:0)
这是因为WebPage类派生自UITableViewController
。取而代之的是UIViewController
。
例如
@interface WebPage : UIViewController <UIWebViewDelegate> {
UIWebView *webView;
NSURL *theUrl;
}