1つのUIViewにUIButton、UIImageViewなどのUIViewをパッケージ化したいとします。私はそのビューを表示しようとすると 、それは私RootViewController上に表示されていません。ここで他のUIViewを含むUIViewサブクラス
は私のUIViewサブクラスのコードです:
#import "Hover.h"
@implementation Hover
- (id)init{
self = [super init];
if (self) {
// Initialization code
UIImage *hover = [UIImage imageNamed:@"Hover.png"];
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = hover;
imageView.frame = CGRectMake(0, 0, hover.size.width, hover.size.height);
imageView.alpha = 0.75;
[self addSubview:imageView];
[imageView release];
}
return self;
}
そしてここでは、RootViewControllerクラスです:
- (void)viewDidLoad
{
Hover *hover = [[Hover alloc] init];
[self.navigationController.view addSubview:hover];
[hover release];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
「ホバービュー」は表示されません!しかし、私は私のRootViewControllerに単一のUIImageViewを追加すると、それは動作します!
はまた、' 'initWithFrameあるUIView'の指定イニシャライザをオーバーライドする必要があります。 – Andriy