我以编程方式实现列表视图控制器
当我尝试运行该项目时,我有错误:
2012-11-07 22:46:34.719 myTableViewControl[12021:c07] The app delegate must implement the         window property if it wants to use a main storyboard file.
2012-11-07 22:46:34.722 myTableViewControl[12021:c07] -[AppDelegate setwindow:]:     unrecognized selector sent to instance 0x7674e70
2012-11-07 22:46:34.723 myTableViewControl[12021:c07] *** Terminating app due to uncaught     exception 'NSinvalidargumentexception',reason: '-[AppDelegate setwindow:]: unrecognized     selector sent to instance 0x7674e70'
*** First throw call stack:
(0x1c8e012 0x10cbe7e 0x1d194bd 0x10df7ea 0x1c7dcf9 0x1c7d94e 0x1d60 0x107b7 0x10da7     0x11fab 0x23315 0x2424b 0x15cf8 0x1be9df9 0x1be9ad0 0x1c03bf5 0x1c03962 0x1c34bb6 0x1c33f44     0x1c33e1b 0x117da 0x1365c 0x1bd2 0x1b05)
libc++abi.dylib: terminate called throwing an exception
(lldb)

当我运行代码时,它挂在main.m上,并显示“thread1:signal SIGABRT”

@autoreleasepool {return UIApplicationMain(argc,argv,nil,NsstringFromClass([AppDelegate class]));

我的代码如下:
AppDelegate.h

//
//  AppDelegate.h
//  myTableViewControl
//
//  Created by Max on 12-11-5.
//  copyright (c) 2012年 Max. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong,nonatomic) UINavigationController *navigationController;


@end

AppDelegate.m

//
//  AppDelegate.m
//  myTableViewControl
//
//  Created by Max on 12-11-5.
//  copyright (c) 2012年 Max. All rights reserved.
//

    #import "AppDelegate.h"
    #import "firstViewController.h"


@implementation AppDelegate
@synthesize navigationController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
    // create the base window
    UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    window.backgroundColor = [UIColor greenColor];
    self.window = window;

    [window release];

    // this is the home page from the user's perspective

    FirstViewController *fvc = [[FirstViewController alloc] init];

    UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:fvc];
    self.navigationController = nc;

    [fvc release];
    [nc release];

    // show them
    [self.window addSubview: nc.view];
    [self.window makeKeyAndVisible];


    return YES;
}

- (void) dealloc
{

    [super dealloc];
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks,disable timers,and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources,save user data,invalidate timers,and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution,this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was prevIoUsly in the background,optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

FirstViewController是列表视图控制器.

解决方法

您正在将窗口创建为局部变量,然后尝试通过使用self.window来访问它,就像它是一个属性一样.使它成为一个财产.

ios – 如果要使用主要的故事板文件,应用程序委托必须实现该窗口属性的更多相关文章

  1. 浅析HTML5中的download属性使用

    这篇文章主要介绍了浅析HTML5中的download属性使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

  2. ios – 如何/是否在Xcode中制作通用故事板

    在Xcode中创建故事板文件时,您必须选择是否适用于iPhone或iPad.这意味着应始终将iPhone和iPadUI放入单独的故事板中.这是真的?我的应用程序有多个故事板.虽然Main.storyboard文件在iPhone和iPad之间存在很大差异,但其他故事板几乎完全相同.唯一的区别可能是推动iPhone与iPhone上的popover,可以通过编程方式处理.制作两个故事板似乎非常愚蠢和多余.因此,如果制作一个“通用”故事板,是否应该在Xcode中选择iPhone或iPad?

  3. ios – Swift:故事板中的本地化 – 标签未添加到Main.strings?

    当我尝试本地化我的应用程序并为目标语言创建一个新的Main.strings文件时,我在界面构建器(标签,按钮,…)中创建的所有内容都会添加到新的Main.strings文件中我可以相应地本地化文本.但是当我稍后在界面构建器中向ViewController添加标签或按钮时,它不会自动添加到Main.strings文件中以获取基本和语言版本.那么,我如何找出按钮/标签的ObjectID是什么,以便我可以将它添加到字符串文件中?

  4. XCode:将故事板导出到图像

    我有一个小问题……

  5. 在ios中将故事板从一个应用程序复制到另一个应用程序的最佳方法是什么?

    或者我在这里遗漏了什么?编辑-1我认为StoryBoard的布局大小仅限于iphone5.解决方法你这样做的方式是正确的.您只是遇到了布局约束不存在或错误的事实.关于故事板没有什么神奇之处……它只是一个像你复制到你的新项目中的任何其他文件.您应该在每个视图控制器中选择您的顶层视图,然后告诉Xcode删除所有约束并将它们重置为建议的约束,然后从那里开始.

  6. ios – Interface Builder无法确定“Main.storyboard”的类型.这可能是由于缺少SDK

    解决方法这没有你想象的那么复杂.该错误是因为您在Main.storyboard的源代码上输错了一些内容,例如我不小心在Main.storyboard的第一个打开标记之前放了一个“”.1)你必须做的是删除Main.storyboard2)转到垃圾箱,将Main.storyboard移动到桌面,用任何文本编辑器打开并修复代码;然后“全选”和“复制”.3)在Xcode上,创建一个全新的Main.storyboard,然后按右键单击文件并选择OpenAs–>源代码,然后粘贴您在剪贴板上的固定代码.4)右键单击文件

  7. ios – storyboard在导入xcassets后为每个图像都有问号

    图片.这是在我将所有媒体资产导入新的.xcassets结构后发生的.该应用程序运行正常,图像显示应用程序运行时,但我该怎么做才能在故事板中恢复它们?解决方法从故事板中的图像名称中删除.png扩展名.Xcode5现在使用图像名称,而不是文件名.

  8. ios – 如何使对象ID具有人类可读性?

    故事板上的每个UIView都有一个唯一的对象ID,类似于:kvf-NI-koG我想知道有没有办法让这个更友好,例如’myLabel’?

  9. ios – 故事板UICollectionViewCell显示,然后变为空白

    问题:我在Storyboard/InterfaceBuilder上使用UIViewController,其中有一个UICollectionView,用于定义UICollectionViewCell.每当我在这个单元格中更改某些内容时,其所有子视图都会变为空白,从而无法看到任何内容.此外,当我更新约束时,即使我刷新,框架也不会移动,就像整个界面构建器被破坏一样.它只适用于这个UIViewContro

  10. ios – UISplitViewController在故事板中隐藏/取消隐藏MasterView

    我有一个简单的iPad应用程序,带有带有tableview的MasterviewController和一个包含UIWebView的DetailViewController.然后我在我的Storyboard中拖放了一个SplitViewController,将它与我的Master和Detail控制器连接起来.在MasterViewController中我使用以下内容:目前看起来如下:一切都很好.我想

随机推荐

  1. iOS实现拖拽View跟随手指浮动效果

    这篇文章主要为大家详细介绍了iOS实现拖拽View跟随手指浮动,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  2. iOS – genstrings:无法连接到输出目录en.lproj

    使用我桌面上的项目文件夹,我启动终端输入:cd然后将我的项目文件夹拖到终端,它给了我路径.然后我将这行代码粘贴到终端中找.-name*.m|xargsgenstrings-oen.lproj我在终端中收到此错误消息:genstrings:无法连接到输出目录en.lproj它多次打印这行,然后说我的项目是一个目录的路径?没有.strings文件.对我做错了什么的想法?

  3. iOS 7 UIButtonBarItem图像没有色调

    如何确保按钮图标采用全局色调?解决方法只是想将其转换为根注释,以便为“回答”复选标记提供更好的上下文,并提供更好的格式.我能想出这个!

  4. ios – 在自定义相机层的AVFoundation中自动对焦和自动曝光

    为AVFoundation定制图层相机创建精确的自动对焦和曝光的最佳方法是什么?

  5. ios – Xcode找不到Alamofire,错误:没有这样的模块’Alamofire’

    我正在尝试按照github(https://github.com/Alamofire/Alamofire#cocoapods)指令将Alamofire包含在我的Swift项目中.我创建了一个新项目,导航到项目目录并运行此命令sudogeminstallcocoapods.然后我面临以下错误:搜索后我设法通过运行此命令安装cocoapodssudogeminstall-n/usr/local/bin

  6. ios – 在没有iPhone6s或更新的情况下测试ARKit

    我在决定下载Xcode9之前.我想玩新的框架–ARKit.我知道要用ARKit运行app我需要一个带有A9芯片或更新版本的设备.不幸的是我有一个较旧的.我的问题是已经下载了新Xcode的人.在我的情况下有可能运行ARKit应用程序吗?那个或其他任何模拟器?任何想法或我将不得不购买新设备?解决方法任何iOS11设备都可以使用ARKit,但是具有高质量AR体验的全球跟踪功能需要使用A9或更高版本处理器的设备.使用iOS11测试版更新您的设备是必要的.

  7. 将iOS应用移植到Android

    我们制作了一个具有2000个目标c类的退出大型iOS应用程序.我想知道有一个最佳实践指南将其移植到Android?此外,由于我们的应用程序大量使用UINavigation和UIView控制器,我想知道在Android上有类似的模型和实现.谢谢到目前为止,guenter解决方法老实说,我认为你正在计划的只是制作难以维护的糟糕代码.我意识到这听起来像很多工作,但从长远来看它会更容易,我只是将应用程序的概念“移植”到android并从头开始编写.

  8. ios – 在Swift中覆盖Objective C类方法

    我是Swift的初学者,我正在尝试在Swift项目中使用JSONModel.我想从JSONModel覆盖方法keyMapper,但我没有找到如何覆盖模型类中的Objective-C类方法.该方法的签名是:我怎样才能做到这一点?解决方法您可以像覆盖实例方法一样执行此操作,但使用class关键字除外:

  9. ios – 在WKWebView中获取链接URL

    我想在WKWebView中获取tapped链接的url.链接采用自定义格式,可触发应用中的某些操作.例如HTTP://我的网站/帮助#深层链接对讲.我这样使用KVO:这在第一次点击链接时效果很好.但是,如果我连续两次点击相同的链接,它将不报告链接点击.是否有解决方法来解决这个问题,以便我可以检测每个点击并获取链接?任何关于这个的指针都会很棒!解决方法像这样更改addobserver在observeValue函数中,您可以获得两个值

  10. ios – 在Swift的UIView中找到UILabel

    我正在尝试在我的UIViewControllers的超级视图中找到我的UILabels.这是我的代码:这是在Objective-C中推荐的方式,但是在Swift中我只得到UIViews和CALayer.我肯定在提供给这个方法的视图中有UILabel.我错过了什么?我的UIViewController中的调用:解决方法使用函数式编程概念可以更轻松地实现这一目标.

返回
顶部