[英]How to load view of xib file in another view controller
Xib File Xib文件
@interface SearchingPropertyViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIView *searchingView
i added the below code to the button action in another ViewController 我将以下代码添加到另一个ViewController中的按钮操作中
SearchingPropertyViewController *ps = [[[NSBundle mainBundle] loadNibNamed:@"SearchingPropertyViewController" owner:self options:nil] objectAtIndex:0];
[self.view addSubview:ps.searchingView];
I just wanted to load searchingView in another view controller 我只是想在另一个视图控制器中加载searchingView
Try this! 尝试这个! Simple solution :) Please find view controller loadview method.
简单的解决方案:)请查找视图控制器loadview方法。 https://developer.apple.com/documentation/uikit/uiviewcontroller/1621454-loadview
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621454-loadview
SearchingPropertyViewController *searchPVC = [[SearchingPropertyViewController alloc]initWithNibName:@"SearchingPropertyViewController" bundle:nil ];
[searchPVC loadView];
[self.view addSubview:searchPVC.textLabel];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.