【问题标题】:Open a WebView URL from Plist?从 Plist 打开 WebView URL?
【发布时间】:2012-07-03 02:07:13
【问题描述】:

有没有办法检索我在 Plist 中的 url 并从中制作 webview?

【问题讨论】:

    标签: iphone objective-c xcode uiwebview plist


    【解决方案1】:

    是的,您可以使用以下方式打开 plist:

    NSString *path = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"your.plist"];
    NSDictionary *plistDictionary = [[NSDictionary dictionaryWithContentsOfFile:path] retain];
    

    然后您将能够在plistDictionary 中找到您的网址。

    【讨论】:

    • 其实url并不是Plist中唯一的东西参数,没关系吧?我必须指定其他内容吗?
    • @CarlosNegron:你应该能够做到[plistDictionary objectForKey:@"key_of_the_url"]
    • 不走运:/这是我的代码:codeNSString *path = [[NSBundle mainBundle] bundlePath]; NSString *finalPath = [路径 stringByAppendingPathComponent:@"Data.plist"]; NSDictionary *plistDictionary = [[NSDictionary dictionaryWithContentsOfFile:finalPath] 保留]; [plistDictionary objectForKey:@"twitter"]; NSLog(@"%@", plistDictionary);
    • @CarlosNegron:不,你需要NSLog(@"%@", [plistDictionary objectForKey:@"twitter"]);
    • 它显示为 (null)。奇怪,它加载了一些文本,因为我可以在 tableview 中看到它,但我只想点击它并打开网站:/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 1970-01-01
    相关资源
    最近更新 更多