Я создаю новое окно UIWindow и хочу показать представление в окне, как представление всплывающего окна, но оно не отображается (код, который я прочитал SVProgressHUD для справки)
код ниже:
В .h файле
#import <UIKit/UIKit.h>
@interface PopoverView : UIWindow
@property (nonatomic, strong) NSArray *items;
- (void)show;
@end
В .m файле
@interface PopoverView ()
@property (nonatomic, assign) UIWindow *prevKeyWindow;
@end
@implementation PopoverView
@synthesize items=_items;
@synthesize prevKeyWindow;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:[[UIScreen mainScreen] bounds]];
if (self) {
self.windowLevel = UIWindowLevelAlert;
// Initialization code
UILabel *view = [[UILabel alloc] initWithFrame:frame];
view.backgroundColor = [UIColor blackColor];
[self addSubview:view];
self.backgroundColor = [UIColor blackColor];
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
return self;
}
- (void)show {
if (![self isKeyWindow]) {
self.prevKeyWindow = [UIApplication sharedApplication].keyWindow;
[self makeKeyAndVisible];
}
}
@end
Кто-нибудь поможет?