Tutorial details

UIPicker With Webviews | App Code for Sale | Preview

UIPicker With Webviews | iOS Tutorial

How to change the URL of a webview with a uIPicker

Overview PAGE TOP

Reference: http://www.geekylemon.com/xcode-picker-with-webviews

In this tutorial i will be showing you how to change the URL of a webview with a uIPicker


  • 1 webview
  • 1 UIPicker

This feature is great for letting the user change between you selected URL links to display in a webview its quick and easy to show users content

ViewController.h PAGE TOP

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
IBOutlet UIPickerView *Picker;
NSArray *PickerData;
IBOutlet UIActivityIndicatorView*activityind;
NSTimer *timer;
IBOutlet UIWebView *Webview;

@property (retain, nonatomic) IBOutlet UIPickerView *Picker;
@property (retain, nonatomic) NSArray *PickerData;
@property (retain, nonatomic) IBOutlet UIWebView *Webview;


ViewController.m PAGE TOP

@implementation ViewController

@synthesize Picker,Webview,PickerData;

- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSArray *array = [[NSArray alloc]initWithObjects:@"Youtube",@"Twitter",@"Facebook",@"Website", nil];
self.PickerData = array;
[Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com/GeekyLemon"]]];
[Webview addSubview:activityind];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0)

-(void)loading {
if (!Webview.loading)
[activityind stopAnimating];
[activityind startAnimating];

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [PickerData count];

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [self.PickerData objectAtIndex:row];

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
int select = row;
if (select == 0) {
[Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com/GeekyLemon"]]];
} else if (select == 1) {
[Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.twitter.com/GeekyLemon"]]];
} else if (select == 2) {
[Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.facebook.com/GeekyLemonDevelopment"]]];
} else if (select == 3) {
[Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.GeekyLemon.com"]]];


Reference PAGE TOP


0 Comments Leave a comment

Please login in order to leave a comment.

Newest first

to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.