gpt4 book ai didi

ios - 当 webViews 尝试在选项卡栏 Controller 中加载时,应用程序崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:57 25 4
gpt4 key购买 nike

所以我的应用程序的前提是它有多个选项卡,每个 tabViewController 都有一个加载不同网页的 webView 属性。

我不确定到底出了什么问题,以及为什么会崩溃。

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6a7c5b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key webView.'

我构建应用程序的方式是为每个选项卡创建单独的 ViewController 类。我将 IBOutlets 包含在 WebView 中,并将它们链接到我在 Storyboard 中包含的 webView。我还将 CustomClass 设置为 ViewController 类。

这是我的代码示例(它在 ViewController 中几乎是同义词):

AmericaViewController.h

#import <UIKit/UIKit.h>
@interface AmericaViewController : UIViewController
@property (nonatomic, weak) IBOutlet UIWebView *webView;
@end

AmericaViewController.m

#import "AmericaViewController.h"
@implementation AmericaViewController
@synthesize webView = _webView;

-(void)viewDidLoad
{
[super viewDidLoad];

// allow user to pinch-zoom page
self.webView.scalesPageToFit = YES;
self.webView.multipleTouchEnabled = YES;

//load webView
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://baylornotes.org/articles/America"]]];
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}

@end

最佳答案

根据异常,您的 UIViewController 之一没有属性 webView。也许你的某个类(class)写得不好,或者你忘记在 xib 中设置正确的类(class)......

关于ios - 当 webViews 尝试在选项卡栏 Controller 中加载时,应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11439298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com