我目前正在尝试创建一个表格,该表格将显示用户正在下载的当前下载内容,并在每个单元格中显示进度条和详细信息。
我正在处理的项目正在使用 xib,而 xib 显然不支持 TableView 中的嵌入部分
Table views with embedded sections and cells are only supported in storyboard documents
我可以将 Storyboard 用于独立的 UITableViewController 吗?如果是怎么办?
对于我想做的事情,还有什么办法可以解决这个问题吗?如果是这样,解决方法是什么?
在此先感谢我在过去的几个小时里一直停留在这个问题上。
self.rootController = [[UITabBarController alloc] init];
ViewController1 *view2 = [[ViewController1 alloc] init];
TableViewController *view3 = [[TableViewController alloc] init];
view3.tabBarItem.title = @"Documents";
appWebView = [[WebViewController alloc] init];
appWebView.title = @"Browser";
appWebView.tabBarItem.title = @"Browser";
view2.title = @"Downloads";
self.rootController.viewControllers = [NSArray arrayWithObjects:appWebView, view2, view3, nil];
self.window.rootViewController = self.rootController;
appWebView.tabBarItem.image = [UIImage imageNamed:@"Browser.png"];
view2.tabBarItem.image = [UIImage imageNamed:@"Download.png"];
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[_window setRootViewController:appWebView];
[_window makeKeyAndVisible];
[_window addSubview:_rootController.view];
^^ 是 AppDelegate,下面是我想使用 Storyboard的 View
@interface TableViewController ()
@end
@implementation TableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"TableViewController" bundle:nil];
TableViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"TableViewController"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:NO completion:nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
最佳答案
当你在Xib(Base Xib)中使用 TableView 时。您必须创建单独的 UITableViewCell。并且您应该在 Base Xib View 中注册 UITableViewCell。请遵循以下代码。
override func awakeFromNib() {
Yourtableview.register(UINib.init(nibName: "cellnibname", bundle: nil), forCellReuseIdentifier: "identifier")
}
关于ios - 在 XIB 中创建嵌入式单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24377861/