开发者

With the help of the segmented control navigating web pages

开发者 https://www.devze.com 2023-03-06 02:06 出处:网络
How to navigate web pages with the help of segmented controls? I do have four web pages I need to navigate, one after the another, can anybody hel开发者_运维知识库p me out?

How to navigate web pages with the help of segmented controls?

I do have four web pages I need to navigate, one after the another, can anybody hel开发者_运维知识库p me out?

Does anybody have the example with this related one?

Thanks in advance.


Fit the view with a UIWebView object and a UISegmentedControl object. Wire an outlet to webView in the controller and connect the segmented control's valueChanged event in IB to a IBAction -changeWebSource:(UISegmentedControl*) and define its implementation as follows –

- (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]];
}

Change the urls as you wish. But I am not sure how this will ensure they visit the pages one after the other as you wanted. Let me know if you need any additional help.


Then see the class reference here

[segmentedControl addTarget:self action:@selector(action:) forControlEvents:UIControlEventValueChanged];
0

精彩评论

暂无评论...
验证码 换一张
取 消