【问题标题】:Using NSArray to store UIWebView for use with UIToolBar使用 NSArray 存储 UIWebView 以供 UIToolBar 使用
【发布时间】:2010-11-12 11:14:30
【问题描述】:

我有一个 WebView、UIToolBar,还有一个下一个按钮和一个上一个按钮。

我有 6 个 HTML 页面需要按下一个或上一个按钮按顺序显示。

例如:从 HTML 页面 1 开始,按下一步并加载 HTML 页面 2。按下一步并加载 HTML 页面 3。依此类推。

UIWebView 目前是这样加载的:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"PrepareEquipment" ofType:@"html"]isDirectory:NO]]];

我希望能够按下下一步按钮并使用下一个 HTML 页面加载 webview。

我该怎么做?应该是 NSArray 还是有更好的方法?

非常感谢大家的帮助。

斯特凡。

【问题讨论】:

    标签: iphone uiwebview nsarray uitoolbar


    【解决方案1】:

    确实有一个简单的问题。

    创建 2 个属性:1 个 NSArray pageList 和 1 个 int currentPage

    首先,您应该将您的 html 页面名称存储在一个数组中(按顺序排列)

    [self.pageList addObject:@"Page1"];
    [self.pageList addObject:@"Page2"];
    [self.pageList addObject:@"Page3"];
    //etc.
    

    点击箭头只是增加或减少 currentPage 然后:

    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[self.pageList objectAtIndex:currentPage] ofType:@"html"]isDirectory:NO]]];
    

    别忘了禁用你的按钮(prev. if currentPage == 0 and next if currentPage == [self.pageList count]-1)

    祝你好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多