gpt4 book ai didi

ios - 未触发 commitEditingStyle

转载 作者:技术小花猫 更新时间:2023-10-29 11:22:00 29 4
gpt4 key购买 nike

我有一个 UITableView,我试图在编辑模式处于事件状态但未触发 commitEditingStyle 时删除一行。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

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

cell.text=[NSString stringWithFormat:@"Row Number %d",indexPath.row];

return cell;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"trying to delete a row..");
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 6;
}

-(void)Edit:(id)sender //Active editing mode
{
[self.table setEditing:YES animated:YES];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(Done:)];
}

我只想删除一行?

这是我显示弹出窗口的方式:

UIPopoverController *popover;
-(IBAction)open:(id)sender
{
CGRect r=((UIButton*)sender).frame;
CGRect tRect=[((UIButton*)sender) convertRect:((UIButton*)sender).frame toView:self.view];
tRect.origin.x=r.origin.x;

Popover *firstViewCtrl = [[Popover alloc] init];

UINavigationController *navbar = [[UINavigationController alloc] initWithRootViewController:firstViewCtrl];
navbar.preferredContentSize = CGSizeMake(300, 300);
popover = [[UIPopoverController alloc] initWithContentViewController:navbar];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(300, 300);

CGRect popRect = CGRectMake(0,
0,
200,
200);

[popover presentPopoverFromRect:popRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];

// [popover presentPopoverFromRect:tRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}

我使用 Xcode 界面创建了 UITableView。

-(void)Done:(id)sender
{
[self.table setEditing:NO animated:NO];
//[self.table endEditing:true];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(Edit:)];
}

enter image description here

最佳答案

当您触摸DELETE 按钮时它会触发,而不是减号...并且由于您的tableview 的宽度,您的tableview 上的删除按钮不会正确显示...

关于ios - 未触发 commitEditingStyle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19389545/

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