メインのViewControllerがあります:
@interface ViewController : UIViewController
そこに私のScreenViewを持つプロパティがあります:@property (strong,nonatomic) MUIScreenView* screenView;
そして、それは次のように呼び出されます:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:_screenView];
}
次に、私の MUIScreenViewClass を見てください。
@interface MUIScreenView : MUIView
@interface MUIView : UIView
私の MUIScreenView にはメソッドがあります:
-(void)addScreenObjectToView
{
MUIButton *button = [[MUIButton alloc] initWithButtonModel:(ButtonModel*)MUIElement
[self addSubview:button];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(10, 220, 300, 40);
[myButton setTitle:@"This is Standard UIButton!" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:myButton];
}
そして、これは何かを描画するための私の MUIButton メソッドです:
-(void)addButtonToView
{
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(10, 50, 300, 40);
[myButton setTitle:@"This is a MUIButton!" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:myButton];
}
そして最後に私は持っています:
トップボタンが死んでいる可能性はありますか?私がそれに触れても何も起こりませんでした。まったく同じ方法で作成しました。
要約 - 「これは MUIButton です!」として現在表示しているもの ビューには別のビューが含まれており、2 番目のビューには UIButton があります。「これは標準の UIButton です!」として UIButton を含むビューです。