ios - 在 XIB 中创建嵌入式单元格?

标签 ios objective-c uitableview

我目前正在尝试创建一个表格,该表格将显示用户正在下载的当前下载内容,并在每个单元格中显示进度条和详细信息。

我正在处理的项目正在使用 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/

相关文章:

Android - 跨平台友好的调试/记录器宏

objective-c - 运行单个测试方法

ios - 如何传递数据类型为 CMTime 的浮点值?

iOS 如何将 IB 自定义类设置为类别

ios - 在静态表格 View 中无法识别 Swift Touches

ios - 如何在 react native map 上获取中心坐标?

swift - 如何获取 UITableView 中的所有 UITextField 值?

ios - DidDeselectRowAtIndexpath 中的 "unexpectedly found nil while unwrapping an Optional value"

objective-c - 有什么方法可以加粗 NSString 的一部分?

带有状态栏的ios模拟器黑屏