【发布时间】:2016-05-17 08:09:35
【问题描述】:
我正在尝试在 xcode 的 uiwebview 中加载一个 url,它加载得很好,但问题是用户与它的交互为零。我不能触摸它上面的任何按钮,甚至不能滚动它。我已经在 info.plist 中尝试过Allow Arbitrary Loads = YES,但这里没有发生任何事情是我的代码。
[webPage setDelegate:self];
[webPage loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://url.com"]]];
[webPage addSubview:activityIndicatorView];
这里有更多来自 .h 的代码:
@interface ViewController : UIViewController<UIWebViewDelegate>{
IBOutlet UIWebView *webPage;
}
@property (retain, nonatomic) IBOutlet UIWebView *webPage;
它的简单 uiwbview 来自简单的 uiviewcontroller 中的界面生成器。 这是我的 info.plist
我发现问题可能出在这部分代码中。我的 uinavigationbar 中还有一个正在加载 xml 菜单的菜单。等等,我会发布我的代码。
- (void) makeMenu{
@try {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,0),^{
NSURL *url=[NSURL URLWithString:@"http://url/xml-menu.php"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSError *error = nil;
NSHTTPURLResponse *response = nil;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if ([response statusCode] >=200 && [response statusCode] <300)
{
rssOutputData = [[NSMutableArray alloc]init];
xmlParserObject =[[NSXMLParser alloc]initWithData:urlData];
[xmlParserObject setDelegate:self];
[xmlParserObject parse];
}
dispatch_async(dispatch_get_main_queue(), ^{
sideMenu.delegate = self;
NSInteger count;
NSMutableArray *itemsArry = [[NSMutableArray alloc] init];
count = [rssOutputData count];
for (int i = 0; i < count; i++){
BTSimpleMenuItem *item = [[BTSimpleMenuItem alloc]initWithTitle:[[rssOutputData objectAtIndex:i]xmltitle] image:[UIImage imageNamed:@"arrow.png"]
onCompletion:^(BOOL success, BTSimpleMenuItem *item) {
[webPage loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[[rssOutputData objectAtIndex:i]xmllink]]]];
}];
[itemsArry addObject:item];
}
NSArray *itemSarry=[[NSArray alloc] initWithArray:itemsArry];
sideMenu = [[BTSimpleSideMenu alloc]initWithItem:itemSarry addToViewController:self];
});
});
}
@catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
}
当我在 viewdidload 中调用此方法时,uiwebview 停止响应。如果我不把这部分称为 uiwebview 就可以了。请帮帮我,我也需要这个菜单。
【问题讨论】:
-
您是否在页面加载后删除了活动指示器???你确定你的 activityIndicatorView 没有阻塞 UI 交互???
-
activityIndicatorView 做得很好,我什至试过没有它,但还是一样
-
http 或 https 等 url 方案不会影响原生组件的 userInteraction :) 你从错误的角度看待问题 :) 你能否提供更多代码,比如你的 webView 怎么样加载??它是作为子视图添加到其他一些 VC 的吗???您正在处理哪些 webView 代表以及您在做什么???
-
请再次查看我的问题,我编辑了它。
-
尝试加载 webView 对我来说效果很好,伙计 :( 不知道你的问题可能是什么
标签: ios objective-c xcode uiwebview info.plist