0
我有两个视图控制器之一是informationViewController和另一个InformationDetailedViewController。有按钮的动作我加载相应的URL PDF文件Inital负载视图控制器将不响应网络视图
// InformationViewController.m
// About Us button clicked
-(void)aboutUsAction:(id)sender{
[informationDetailedViewController showInformation:0];
[self.navigationController pushViewController:informationDetailedViewController animated:YES];
}
// Terms and condition button clicked
-(void)termsAndConditionAction:(id)sender{
[informationDetailedViewController showInformation:1];
[self.navigationController pushViewController:informationDetailedViewController animated:YES];
}
// InformationDetailedViewController.m
- (void)viewDidLoad{
[super viewDidLoad];
// create a webview
webInfoDetailed = [[UIWebView alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height)];
webInfoDetailed.scalesPageToFit = YES;
[webInfoDetailed setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:webInfoDetailed];
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:YES];
}
// InInformationDetailedViewController.1
-(void)showInformation:(int)informationId {
NSString *informationType = @"";
switch (informationId) {
case 0:
self.title = @"About Us";
informationType = KHABOUTUS;
break;
case 1:
self.title = @"Disclaimer";
informationType = KHDISCLAIMER;
break;
default:
break;
}
NSURL *targetURL = [NSURL URLWithString:informationType];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webInfoDetailed loadRequest:request];
}
的问题是在初始加载(第一次加载)的网址是不是装上webView的两粒扣。 当点击返回,然后点击关于我们或条款和条件它的工作完美。它是我在这里失踪的非常小的东西。 @所有感谢提前
它不起作用,因为在调用showInformation时Web视图未加载:0。你在这个声明之后推动它。然后加载webview。所以要解决这个问题。您将一个整数传递给详细视图。从详细视图中,您应该调用showInformation函数:x。 x是整数属性。让我知道你是否需要这个代码。 – Jassi 2015-04-05 14:16:40
@Jassi感谢您的输入!它的固定 - (void)viewWillAppear:(BOOL)动画{super viewWillAppear:YES]; NSLog(@“typeID%d中的值”,typeID); [self showInformation:typeID]; } – kiran 2015-04-05 14:46:30