Hamza KAVAK
Hamza KAVAK

Reputation: 67

How to I Pull to refresh in webview

I am new learning.

I made a UIWebView on Xcode.

Refresh Code simulator is working but not working on the phone. How to ı can run?

Here is code

-(void)viewDidLoad {
     NSString *fullURL = @"http://mysite.com.tr/report";
     NSURL *url = [NSURL URLWithString:fullURL];
     NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
     webView.delegate = (id)self;
     [webView loadRequest:requestObj];

     UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
     [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
     [webView.scrollView addSubview:refreshControl];
}


-(void)handleRefresh:(UIRefreshControl *)refresh {

    // Reload my data

    NSString *fullURL = @"http://mysite.com.tr/report";
    NSURL *url = [NSURL URLWithString:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
    [refresh endRefreshing];
    [super viewDidLoad];

}

Upvotes: 0

Views: 355

Answers (1)

elk_cloner
elk_cloner

Reputation: 2149

Your code is working fine. remove

 [super viewDidLoad];

And in info.plist file add a property.

enter image description here

Note: Allow arbitrary Loads to YES is not recommended though.Hope you'll figure it out by yourself.

Upvotes: 1

Related Questions