我有一个UIView
设计的XIB
文件。基本上带有一个导航栏和一个按钮来关闭UIVIew
. 我想UIView
在UIViewControllers
整个应用程序中展示这个。下面是我到目前为止所使用的代码[emnted。但是UIView
没有出现。
我ViewControllers
的设计是在storyboard
但是我需要一个简单的 UIView,这就是为什么我创建了一个新的 UIView 自定义子类以及一个同名的 xib 文件。文件的所有者也设置为自定义子类。这里还需要什么?
@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.
}