• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - Xcode 中的 IB 连接崩溃

[复制链接]
菜鸟教程小白 发表于 2022-12-13 11:56:16 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

昨晚我去测试我的 iOS 应用程序时,它在启动时崩溃了。我什至没有研究导致崩溃的 Nib 。无论如何,这是错误代码:

2/29/12 10:32:05.291 AM Safe Flight: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0xdd496f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Airport1.'
*** First throw call stack:
(0x2873052 0x33add0a 0x2872f11 0x1ae2032 0x1a53f7b 0x1a53eeb 0x1a6ed60 0x136191a 0x2874e1a 0x27de821 0x136046e 0x1362010 0x114214a 0x1142461 0x11417c0 0x1150743 0x11511f8 0x1144aa9 0x37b7fa9 0x28471c5 0x27ac022 0x27aa90a 0x27a9db4 0x27a9ccb 0x11412a7 0x1142a9b 0x3710 0x2f35)

Airport1 只是一个标签,其中有一个 正确 连接到它的 IBOutlet。另外,如果我删除连接,错误只是与下一个有连接的项目有关。

另外,我的 FileOwners 类正确设置为适当的 viewController。

//  MasterViewController.h

#import <UIKit/UIKit.h>
#import "MobclixAds.h"

@class DataViewController;
@class EditViewController;
@class SearchViewController;



@interface MasterViewController : UIViewController{

    UILabel *Airport1;
    UILabel *Airport2;
    UILabel *Airport3;
    UILabel *Airport4;
    UILabel *Airport5;
    UILabel *Airport6;
    UILabel *Airport7;
    UILabel *Airport8;
    UILabel *Airport9;
    UIButton *Airport1B;
    UIButton *Airport2B;
    UIButton *Airport3B;
    UIButton *Airport4B;
    UIButton *Airport5B;
    UIButton *Airport6B;
    UIButton *Airport7B;
    UIButton *Airport8B;
    UIButton *Airport9B;

    MobclixAdView* adView;
}

@property (strong, nonatomic) DataViewController *dataViewController;
@property (strong, nonatomic) EditViewController *editViewController;
@property (strong, nonatomic) SearchViewController *searchViewController;


@property (nonatomic, retain) IBOutlet UILabel *Airport1;
@property (nonatomic, retain) IBOutlet UILabel *Airport2;
@property (nonatomic, retain) IBOutlet UILabel *Airport3;
@property (nonatomic, retain) IBOutlet UILabel *Airport4;
@property (nonatomic, retain) IBOutlet UILabel *Airport5;
@property (nonatomic, retain) IBOutlet UILabel *Airport6;
@property (nonatomic, retain) IBOutlet UILabel *Airport7;
@property (nonatomic, retain) IBOutlet UILabel *Airport8;
@property (nonatomic, retain) IBOutlet UILabel *Airport9;
@property (nonatomic, retain) IBOutlet UIButton *Airport1B;
@property (nonatomic, retain) IBOutlet UIButton *Airport2B;
@property (nonatomic, retain) IBOutlet UIButton *Airport3B;
@property (nonatomic, retain) IBOutlet UIButton *Airport4B;
@property (nonatomic, retain) IBOutlet UIButton *Airport5B;
@property (nonatomic, retain) IBOutlet UIButton *Airport6B;
@property (nonatomic, retain) IBOutlet UIButton *Airport7B;
@property (nonatomic, retain) IBOutlet UIButton *Airport8B;
@property (nonatomic, retain) IBOutlet UIButton *Airport9B;

@property(nonatomic,retain) IBOutlet MobclixAdView* adView;


@end

// MasterViewController.m


#import "MasterViewController.h"

#import "DataViewController.h"
#import "EditViewController.h"
#import "SearchViewController.h"



@implementation MasterViewController

@synthesize dataViewController = _dataViewController;
@synthesize editViewController = _editViewController;
@synthesize searchViewController = _searchViewController;



@synthesize Airport1, Airport2, Airport3, Airport4, Airport5, Airport6, Airport7, Airport8, Airport9;
@synthesize Airport1B, Airport2B, Airport3B, Airport4B, Airport5B, Airport6B, Airport7B, Airport8B, Airport9B;
@synthesize adView;


- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)nibBundleOrNil
{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"Safe Flight";
        self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
    }
    return self;
}

我的代码有问题吗?还是 Xcode 本身?我重新启动了 Xcode 和模拟器,甚至做了一个“干净”的构建(听起来会有所帮助......)

谢谢, 安德鲁

编辑这是我的 AppDelegate,我正在为窗口设置正确的 xib

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
{
    [Mobclix start];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName"MasterViewController" bundle:nil];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;

}

问题解决了!!!

由于一些愚蠢的垃圾邮件过滤器,我无法回答自己的问题...我可以发布问题的图片...但它已修复!

但是这里是问题的链接click here



Best Answer-推荐答案


发现问题!!我现在觉得有点傻;)但无论如何,这是问题的截图!

Devices "Main Interface" had been unintentionally set

关于ios - Xcode 中的 IB 连接崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9503536/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap