2017-04-05 53 views
0

我有UIViewcontroler其具有两个组件的大小宽度之一UITableView占用:120和高度:603UIViewcontroller和另一个UIView(的DetailView)相关的屏幕。 (尺寸宽度:255 &身高:603如何自动调节的UIView帧到另一帧的UIView

现在我定制UIView创建(customView)现在我想补充它的DetailView,它不适合UIView

的DetailView Frame是UIViewController中的一半查看大小。 定制视图帧正常即宽度375 &高度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的屏幕调整。 的理解来解决框架

@Thanks提前

+0

什么是detailView.frame中的loadView方法?你在哪里调用这个方法? –

+0

@TejaNandamuri CustomView.frame = detailView.bounds;它有助于解决这个问题。我一会儿就哑了。 :d – kiran

回答

0

的问题是您在的DetailView的框架设置为您customView并添加customView到您的DetailView你的建议将是有益的。

设置自定义视图的框架,请使用以下代码:

customView.frame = (CGRect){ 
    .origin = CGPointZero, 
    .size = detailView.frame.size 
    }; 

希望充分,这将解决您的问题。

0

你的loadView方法是这样写下面

-(void)loadView { 

NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil]; 
customView = [nibObjects objectAtIndex:0]; 
customView.frame = CGRectMake(0, 0, detailView.frame.size.width, detailView.frame.size.height); 
customView.layer.shadowColor = [UIColor blackColor].CGColor; 
customView.layer.shadowRadius = 1.0f; 
customView.layer.shadowOpacity = 1; 
customView.layer.shadowOffset = CGSizeZero; 
customView.layer.masksToBounds = YES; 
[detailView addSubview:customView]; 

}