私は自分の UIView を持っています:
#import <UIKit/UIKit.h>
@interface MultipleSlotsClientView : UIView
-(IBAction)didPressCloseBtn:(id)sender;
@end
そして、これは実装です:
@implementation MultipleSlotsClientView
- (id)initWithFrame:(CGRect)frame {
self = [[[[NSBundle mainBundle] loadNibNamed:@"MultipleSlotsClientView" owner:self options:nil] objectAtIndex:0] retain];
if (self) {
self.frame = frame;
}
return self;
}
#pragma mark
#pragma mark IBAction
-(IBAction)didPressCloseBtn:(id)sender {
[self removeFromSuperview];
}
@end
メソッドに接続するdidPressCloseBtn
ボタンがあり、ボタンを押すとメソッドが呼び出されますが、ビューはスーパービューから削除されません。
これは、UIView を割り当てて追加する方法です。
MultipleSlotsClientView *multiView = [[[MultipleSlotsClientView alloc] initWithFrame:self.view.frame] autorelease];
[self.view addSubview:multiView];
ビューが消えない理由は何ですか?