UIView存在nib时,不能使用alloc init,正确的方法如下:

1 NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil];
2 UIView *tmpCustomView = [nib objectAtIndex:0];

 其中对应的nib文件应设置file owner。

这样就可以使用nib中的UIView了。

 

相关文章:

  • 2021-11-23
  • 2022-02-08
  • 2022-01-03
  • 2021-04-28
  • 2022-01-01
  • 2022-12-23
猜你喜欢
  • 2021-08-28
  • 2021-06-28
  • 2021-12-31
  • 2021-12-25
  • 2021-05-25
  • 2022-02-01
相关资源
相似解决方案