【发布时间】:2017-04-05 14:19:13
【问题描述】:
我有UIViewcontroler,它占用了两个组件,一个UITableView 的大小Width: 120 和Height:603 的UIViewcontroller 和另一个UIView (detailView) 相关屏幕。 (尺寸宽度:255 & 高度:603)
现在我在自定义 UIView (customView) 上创建,现在我想将它添加到 detailView 上,这不适合 UIView
detailView Frame 是 uiviewcontroller 视图大小的一半。 自定义视图框架是正常的,即 width 375 & height 667
-(void)loadView {
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil];
customView = [nibObjects objectAtIndex:0];
customView.frame = detailView.frame;
customView.layer.shadowColor = [UIColor blackColor].CGColor;
customView.layer.shadowRadius = 1.0f;
customView.layer.shadowOpacity = 1;
customView.layer.shadowOffset = CGSizeZero;
customView.layer.masksToBounds = YES;
[detailView addObject:customView];
}
CustomView 不会在 detailView UIView 屏幕上自动调整。 您的建议将有助于理解修复框架
@提前致谢
【问题讨论】:
-
loadVIew 方法中的 detailView.frame 是什么?你在哪里调用这个方法?
-
@TejaNandamuri CustomView.frame = detailView.bounds;它有助于解决问题。我傻了一会儿。 :D
标签: ios objective-c uiview