我重写tableView:commitEditingStyle:forRowAtIndexPath成为重置我的uitableviewcells中的文本标签的方法,但是当用户接下来触及时会导致错误uitableview ..在它做任何事之前它必须被触摸一次(所以需要两次触摸才能真正得到任何回应)。桌面视图删除错误后,触摸界面后的ViewView:commitEditingStyle:forRowAtIndexPath:已被使用
我希望有人可以帮助谁也曾经处于类似的情况;我的代码如下..我debuged下来的的tableView:commitEditingStyle:forRowAtIndexPath方法,如果我注释掉实现代码如下:titleForDeleteConfirmationButtonForRowAtIndexPath:方法同样的事情仍然发生。所以我觉得我做错了什么通过覆盖其他方法。
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Clear";
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
//[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
//reset uitableviewcell textlabel with default input "empty"
vehicleSearchObjectString = @"empty";
[self.tableView reloadData]; //reloads the tabels so you can see the value.
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
UPDATE 这是我把我的UITableViewCell为textLabel
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"VehicleSearchCell" owner:self options:nil];
cell = vehicleSearchCell;
self.vehicleSearchCell = nil;
}
// Configure the cell...
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
UILabel *label1;
label1 = (UILabel *)[cell viewWithTag:1];
label1.text = @"Manufacture";
UILabel *label2;
label2 = (UILabel *)[cell viewWithTag:2];
label2.text = vehicleSearchObjectString;
}
//...
什么是错误/问题?崩溃?什么? – Bourne
一旦我按下按钮,单元格的uitextlabel设置为“空”,如果我尝试按下该文本单元格(它应该带我到子视图)它dosnt响应第一次触摸..它响应第二..它就像我的整个uitableview变得没有反应。 –
vehicleSearchObjectString:这是什么?你在哪里设置它触摸(将被删除)tableViewCell? – Bourne