ios - 无法声明另一个窗口

标签 ios window appdelegate

我正在尝试在 MyThing.m 中声明另一个窗口

@property (nonatomic, strong) UIWindow *window;

但是得到这个错误

Illegal redeclaration of property in class extension "MyThing" (attribute must be 'readwrite', while its primary must be 'readonly')

如果我将窗口重命名为其他名称,也可以。这是为什么?窗口是否意味着在 AppDelegate.h 中声明一次?

最佳答案

我弄明白问题了,跟AppDelegate.h中声明的window属性没有关系

问题是 MyThing 符合 UIApplicationDelegate,并且 UIApplicationDelegate 协议(protocol)声明了一个属性

@property (nonatomic, retain) UIWindow *window NS_AVAILABLE_IOS(5_0);

所以我们必须做其中任何一个

MyThing.h(就像 AppDelegate.h 一样)

@interface MyThing : NSObject <UIApplicationDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

MyThing.m(综合协议(protocol)声明的窗口属性)

@implementation WYNAppDelegate

@synthesize window;

@end

关于ios - 无法声明另一个窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24715715/

相关文章:

iOS:NSUserDefault 在 AppDelegate 中加载速度不够快?条件间歇性失败

ios - 收到 iOS 推送通知时打开 View Controller

iphone - 登录到主应用程序

javascript - 如何为潮汐Sdk应用程序窗口设置固定大小?

OpenCV 窗口总是在最上面

java - 纹理未正确加载 slick java

ios - APPDelegate 中的 openURL 转换错误 NSString -> String (Swift & iOS8)

ios - 我已经为 UITableView 的单元格设置了值,但为什么它没有显示?

ios - 在 Objective C 中使用代理同时快速发送请求

ios - 未在自定义 View 中调用 UIButton 操作