gpt4 book ai didi

iphone - UITableView 编辑模式不工作

转载 作者:可可西里 更新时间:2023-11-01 03:04:16 25 4
gpt4 key购买 nike

我正在尝试激活 UITableView 的编辑模式。当我单击“编辑”按钮时,它变为“完成”,但表格中没有显示圆形红色减号。我在下面发布了该类(class)的一些方法。应用程序委托(delegate)创建了一个选项卡栏,选项卡内的 View 具有导航 Controller 。一切都在代码中完成,很少用 nib 文件完成。怎么了?

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  
return [ikub.subscriptions count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
int i = [indexPath row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
Subscriptions *s = [ikub.subscriptions objectAtIndex:i];
cell.textLabel.text = [s title];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ artikuj te rinj, %@ artikujt te lexuar", [s new], [s read]];
if (deleteActive) {
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Subscriptions *s = [ikub.subscriptions objectAtIndex:[indexPath row]];
NSString *address = [[NSString alloc] init];
NSString *type = [NSString stringWithString:[s type]];
if ([type isEqualToString:@"Category"]) {
address = [NSString stringWithFormat:@"http://www.ikub.al/Rss.aspx?node=9e26cdb8-dba6-4504-8bb6-29f0753be179~%@", [s code]];
} else if ([type isEqualToString:@"Tag"]) {
address = [NSString stringWithFormat:@"http://www.ikub.al/Rss.aspx?tag=%@", [s code]];
}
address = [address stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
SubscriptionStories *ss = [[SubscriptionStories alloc] init];
ss.address = address;
ss.title = [s title];
[self.navigationController pushViewController:ss animated:YES];
[ss release];
}
- (void)viewWillAppear:(BOOL)animated {
[subscriptionsTable reloadData];
}
- (void)viewDidLoad {
refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:nil];
self.navigationItem.leftBarButtonItem = refreshButton;
[refreshButton release];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
[super viewDidLoad];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}

最佳答案

继承对其没有任何影响。

您可以使用此方法,当您将 navigationController 的右键分配给它时它会起作用。

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[tableView setEditing:editing animated:YES];
}

或者你可以编写一个基本上切换 UITableView 状态的方法,比如

[tableView setEditing:TRUE];

当按钮完成后,将其切换为

[tableView setEditing:FALSE];

关于iphone - UITableView 编辑模式不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4551589/

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