uiwebview不使用HTTP或HTTPS URL

时间:2016-05-17 08:09:36

标签: ios objective-c xcode uiwebview info.plist

我正在尝试在xcode中加载uiwebview中的url并且加载得很好,但问题是ZERO用户与它进行了交互。我无法触摸任何按钮或甚至无法滚动它。我已经在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;

简单的uiview控制器中的界面构建器的简单uiwbview。 这是我的info.plist

enter image description here

我发现代码的这一部分可能存在问题。我的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工作得很好。请帮帮我,我也需要这个菜单。

1 个答案:

答案 0 :(得分:0)

试试这个:

webPage.userInteractionEnabled = YES;