iOS-加载xib
有人知道为什么当我使用这段代码时,它不能将视图缩放到屏幕大小吗。它看起来像是按原样加载xib文件,不适合设备的宽度iOS-加载xib,ios,uiview,xib,Ios,Uiview,Xib,有人知道为什么当我使用这段代码时,它不能将视图缩放到屏幕大小吗。它看起来像是按原样加载xib文件,不适合设备的宽度 - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ReceiptView" owner:self optio
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ReceiptView" owner:self options:NULL];
self = (ReciptView *)[nib objectAtIndex:0];
}
return self;
}
这是控制器中的实现:
-(void) bookNowAction
{
ReciptView *v = [[ReciptView alloc] initWithFrame:self.view.frame];
[self.view addSubview:v];
}
在调用super initWithFrame之后,正在if块中重新分配self。你基本上消除了那个电话的影响