【问题标题】:how to pass local html files using array in xcode如何在xcode中使用数组传递本地html文件
【发布时间】:2023-03-24 20:32:01
【问题描述】:

我在这里尝试申请, 当我单击表格视图时,它将重定向到另一个称为详细信息的页面。在那里,我使用了 webview 来显示选定的 url 值。 这是我的代码

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];

    self.navigationItem.title=@"sample";
    servicesArray=[[NSMutableArray alloc]init];
    [servicesArray addObject:@"1"];
    [servicesArray addObject:@"2"];
    [servicesArray addObject:@"3"];

    urlsArray=[[NSMutableArray alloc]init];
    [urlsArray addObject:@"http://www.google.com"];
    [urlsArray addObject:@"http://www.yahoo.com"];
    [urlsArray addObject:@"http://www.facebook.com"];


}

这里我想传递我的本地 html 文件,而不是 urls 链接。你能帮帮我吗

谢谢 钦图

【问题讨论】:

    标签: ios uitableview uiwebview


    【解决方案1】:

    试试这样,把所有的html文件名都放在Array yourArray中。

    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:[yourArray objectAtIndex:selectedIndex] ofType:@"html" inDirectory:nil];
    NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
    [WebView loadHTMLString:htmlString baseURL:nil];
    

    【讨论】:

    • 4errors 预期的 ':' 在声明的末尾缺少 '[' 在消息发送表达式的开头使用未声明的标识符 'htmlArray'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-16
    • 2012-02-18
    • 2011-07-21
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多