Iphone 借助分段控件导航网页
如何借助分段控件导航网页 我有四个网页需要浏览,一个接一个,有人能帮我吗 有人有这个相关的例子吗Iphone 借助分段控件导航网页,iphone,ipad,Iphone,Ipad,如何借助分段控件导航网页 我有四个网页需要浏览,一个接一个,有人能帮我吗 有人有这个相关的例子吗 提前感谢。然后查看课堂参考资料 使用UIWebView对象和UISegmentedControl对象调整视图。将插座连接到控制器中的webView,并将IB中分段控件的valueChanged事件连接到iAction-changeWebSource:(UISegmentedControl*),并定义其实现如下- - (IBAction)changeWebSource:(UISegmentedCont
提前感谢。然后查看课堂参考资料
使用
UIWebView
对象和UISegmentedControl
对象调整视图。将插座连接到控制器中的webView
,并将IB中分段控件的valueChanged
事件连接到iAction-changeWebSource:(UISegmentedControl*)
,并定义其实现如下-
- (IBAction)changeWebSource:(UISegmentedControl*)sender {
NSURL *sourceURL;
switch ([sender selectedSegmentIndex]) {
case 0:
sourceURL = [NSURL URLWithString:@"http://www.google.com"];
break;
case 1:
sourceURL = [NSURL URLWithString:@"http://www.facebook.com"];
break;
case 2:
sourceURL = [NSURL URLWithString:@"http://www.amazon.com"];
break;
case 3:
sourceURL = [NSURL URLWithString:@"http://www.microsoft.com"];
break;
default:
break;
}
[webView loadRequest:[NSURLRequest requestWithURL:sourceURL]];
}
根据需要更改URL。但我不确定这将如何确保他们按照您的要求一页接一页地访问页面。如果您需要任何其他帮助,请告诉我。分段控件或页面控件?当用户选择分段控件中的选项时,是否要导航?yeap Pratikshabishikar。。。。。。。那太完美了……如果我有N个URL页面,并且我需要使用这些相关的ID访问,那么使用数组并让segmentIndex映射到arrayIndex呢。
- (IBAction)changeWebSource:(UISegmentedControl*)sender {
NSURL *sourceURL;
switch ([sender selectedSegmentIndex]) {
case 0:
sourceURL = [NSURL URLWithString:@"http://www.google.com"];
break;
case 1:
sourceURL = [NSURL URLWithString:@"http://www.facebook.com"];
break;
case 2:
sourceURL = [NSURL URLWithString:@"http://www.amazon.com"];
break;
case 3:
sourceURL = [NSURL URLWithString:@"http://www.microsoft.com"];
break;
default:
break;
}
[webView loadRequest:[NSURLRequest requestWithURL:sourceURL]];
}