0

我已经尝试了所有推荐的方法,SOF但仍然无法解决我的问题。

这是在我的UITableView didSelectRowAtIndexPath

  if ([[[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:@"action"] isEqualToString:@"a9"]||[[[AryStoreknowItem2 objectAtIndex:indexPath.row] objectForKey:@"action"] isEqualToString:@"a9"]){

       NSString *a9 = [[AryStoreknowItem objectAtIndex:indexPath.row] objectForKey:@"content"];

       NSLog(@" url from XML; %@  ",a9);

       webView *web=[[webView alloc]init];
       [web viewDidLoad];//go to webView page

当我选择这一行时,它会从 XML 中检测 URL 并打开UIWebView但它不起作用。显示它检测到NSLog这些网址;http://www.google.com

网页浏览页面;

#import "webView.h"
#import "inboxData.h"

@interface webView ()

@end

@implementation webView

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *a9 = [defaults objectForKey:@"a9"];

    NSLog(@"URL from inboxData get from XML detect >>> %@",a9);

    NSURL *url = [NSURL URLWithString:a9];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:requestObj];

}

谁能给任何想法如何解决这个问题?

4

1 回答 1

0

您的代码似乎不完整// 首先您没有显示添加 uiwebview 的位置......或者如果您UIWebView在另一个屏幕中,那么您没有显示您是否已导航到该屏幕。

因此,从您提供的代码中,我可以告诉您,您必须将 UIWebView 添加到某些视图中,因此无法显示..当然..

所以只需尝试通过以下方式添加带有一些框架的 UIWebview

正如你所说,我刚刚用简单的字符串尝试了你的代码,你确定你的字符串以正确的方式出现......并且它对我有用......

   NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    UIWebView *web=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 100)];
    // above i had set the frame for UIWebView

    [web loadRequest:requestObj];
    web.delegate = self;
    [ParentView addSubview:web];//here i am adding the UIWebiView

Parentview将是您要添加 UIWebView 的视图

于 2013-10-18T07:21:15.900 回答