gpt4 book ai didi

ios - 如何在 webview 中拉动刷新

转载 作者:行者123 更新时间:2023-11-29 00:19:26 25 4
gpt4 key购买 nike

我是新来的学习者。

我在 Xcode 上制作了一个 UIWebView

刷新代码模拟器正在运行,但在手机上不起作用。如何运行?

这是代码

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

}

最佳答案

您的代码运行良好。删除

 [super viewDidLoad];

然后在 info.plist 文件中添加一个属性。

enter image description here

注意: Allow arbitrary Loads to YES is not recommended though.希望你自己弄明白。

关于ios - 如何在 webview 中拉动刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44431183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com