gpt4 book ai didi

ios - 将表格单元格添加到 iOS 中特定部分的表格

转载 作者:行者123 更新时间:2023-11-28 21:31:07 25 4
gpt4 key购买 nike

如果你要添加文档的链接,请不要那样做

我有一个问题她,我不知道如何解决,需要一个明确的答案

我已经从 xcode UI 构建了一个 TableView ,并添加了 5 个部分,每个部分包含一些单元格,除了 section2,我想做的是在 viewDidLoaded 中将单元格添加到 section2 是否可能

这是头文件

@interface Menu : UITableViewController;

这是实现文件

@implementation Menu
@synthesize drawerTableView;

- (void) viewDidLoad {

NSDictionary *object = [drawerTableView dataSource];

KhawaterDataManager *sharedManager = [KhawaterDataManager instance];
CategoriesResponse *categories = [sharedManager categories];
[categories printObject];

}

/*- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

NSLog(@"%d", section);

switch (section) {
case 1:
return 5;
break;

}

return [tableView.dataSource[section] count];
}*/

/*- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: cellIdentifier];

if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}

[cell setBackgroundColor:[UIColor colorWithRed:.8 green:.8 blue:1 alpha:1]];
cell.textLabel.text = @"hello";
return cell;
}*/


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath{

// my logic
}

@end

enter image description here

最佳答案

我认为您在 UITableView 中使用了静态单元格。您可以做的是使用动态表格 View 单元格。您必须取消注释并使用这两种方法来创建您的单元格:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

关于ios - 将表格单元格添加到 iOS 中特定部分的表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36066632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com