UIViewデザインインXIBファイルがあります。基本的に、ナビゲーションバーとを閉じるためのボタンがありますUIVIew。これをアプリ全体UIViewでいくつか表示したいと思います。UIViewControllers以下は私がこれまでに実装したコードです。ただし、UIViewは表示されません。
私ViewControllersはで設計されてstoryboardいますが、単純なUIViewが必要だったため、同じ名前のxibファイルとともにUIViewの新しいカスタムサブクラスを作成しました。ファイルの所有者もカスタムサブクラスに設定されています。ここで他に何が必要ですか?
@interface BottomSlidingView : UIView   //this is my UIView
{
}
@implementation BottomSlidingView          
 - (id)initWithFrame:(CGRect)frame
 {
   self = [super initWithFrame:frame];
   if (self) {
   [self setUserInteractionEnabled:YES];
   NSLog(@"Bottom View Loaded");   //I get this log entry but the view doesn't showup.
}
    return self;
  }
- (BOOL)loadMyNibFile {
if (![[NSBundle mainBundle] loadNibNamed:@"BottomSlidingView" owner:self options:nil]) {
    return NO;
}
    return YES;
}
UIViewそして、これは私が私のカスタムを呼び出す方法ですUIViewController。
 -(void)shareButton:(UIBarButtonItem *)button
 {
   NSLog(@"share button clicked");
   BottomSlidingView *bsv = [[BottomSlidingView alloc] initWithFrame:CGRectMake(20, 480, 280, 420)];
   [bsv loadMyNibFile];
   [self.view insertSubview:bsv belowSubview:self.optionsToolBar]; //this toolbar is a subview that I am adding to this view controller.
 }