iphone - 如何在 iOS 中从 webview 返回到 rootview?

标签 iphone objective-c ios webview barcode-scanner

我是 iOS 和 Objective C 编程世界的新手。我正在尝试创建一个将扫描条形码然后使用该数据访问网站的应用程序。

现在,唯一的问题是当我使用 webview 加载网站时,我不知道如何返回到 mainview/rootview。因为,我已经把它做成了一个基于 View 的应用程序,我不知道如何实现导航 Controller 或者只是一个后退按钮就可以了。

我用过这个 SDK:http://zbar.sourceforge.net/iphone/sdkdoc/

编码:

- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    // ADD: get the decode results
    id<NSFastEnumeration> results =
    [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol *symbol = nil;
    for(symbol in results)
        // EXAMPLE: just grab the first barcode
        break;
    // EXAMPLE: do something useful with the barcode data
    resultText.text = symbol.data;

    CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0);
    UIWebView *webView= [[UIWebView alloc] initWithFrame:webFrame];
    [webView setBackgroundColor:[UIColor whiteColor]];
    NSString *urlAddress= @"http://www.flipkart.com/search/a/books?query=";
    urlAddress =[urlAddress stringByAppendingString:resultText.text];
    NSURL *url= [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj= [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
    [self.view addSubview:webView];
//    [webView release];

/*    


    // ADD: dismiss the controller (NB dismiss from the *reader*!)
    [reader dismissModalViewControllerAnimated: YES]; 
}

如何在 webview 中添加后退按钮以便返回主视图?

最佳答案

关于iphone - 如何在 iOS 中从 webview 返回到 rootview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9858947/

相关文章:

ios - 在选定的时间范围内修剪视频

iphone - 多值url通讯录iphone

iPhone 6/6 Plus 上的 iOS 8 键盘布局

ios - Xcode Reverted to old version,如何恢复?

ios - CGPointZero 和 CGContextDrawImage 不可用

ios - 带有 UISwitch 的 UITableViewCell 不会重绘?

iphone - 在源代码管理中跟踪 Xcode 项目有哪些方法?

iphone - 触摸(点击)事件的顺序

objective-c - NSTextField 的子类化

iphone - 将动态生成的音频文件从iPhone应用程序导出到iPhone iTunes