我想加載一個URL在uiwebview中的xcode,它加載的很好,但問題是有零用戶與它的交互。我無法觸摸它上面的任何按鈕,甚至無法滾動它。我已經在info.plist中嘗試過Allow Arbitrary Loads = YES
,但這裏沒有發生任何事情是我的代碼。uiwebview無法使用HTTP或HTTPS網址
[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;
以S簡單的一個簡單的UIViewController從界面生成器uiwbview。 這裏是我的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是做得很好,我甚至嘗試過沒有它但仍然是相同的 –
url方案像http或https不會影響本地組件夥伴的userInteraction :)你從錯誤的角度看問題:)你可以提供一個更多的代碼,比如你的webView加載如何?它作爲一個子視圖添加到其他一些VC?你正在處理什麼webView的代表以及你在做什麼? –