这样做的方法是,向左滑动单元格。按下删除按钮,它访问本地数据库并删除带有相关数据的行。然而,这不是正在发生的事情。
var gulp = require('gulp');
var jade = require('gulp-jade');
gulp.task('markup', function() {
gulp.src('jade/**/*.jade')
.pipe(jade().on('error', jade.logError))
.pipe(gulp.dest('/build'));
});
因此它创建了一个包含行id的字典。然后初始化连接类,从表中删除行(可以工作),将表中填充- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//add code here for when you hit delete
NSDictionary *dict = [_sourceData valueForKey:[NSString stringWithFormat:@"%li", indexPath.row]];
Connection *connection = [[Connection alloc] init];
[connection removeRowFromTable:@"sources" withRowID:[dict valueForKey:@"id"]];
[self loadData];
NSLog(@"%@", _sourceData);
[_sourceTable reloadData];
}
} //Delete Data Cell
的数据加载到表中。记录正确记录的_sourceData以删除正确的记录。但是,重新加载源表的数据不起作用。它会删除_sourceData
行,但不会删除正确的行。然后,如果我要退出该视图控制器并返回它,它将显示正确的数据。
例如,如果我删除第一行,它将从tableview上的视图中删除第二行,然后,当我返回到视图控制器时..它现在被删除了正确的。
_sourceData记录正确的数据,tableView没有显示它。
我将提供所有tableView方法来提供帮助。
a
答案 0 :(得分:0)
好吧,我是个白痴忘记了我是手动添加标签而不是使用传统方法。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
for (UIView *i in cell.subviews) {
if ([i isKindOfClass:[UILabel class]]) {
[i removeFromSuperview];
}
}
....
在添加新数据之前从该单元格中删除以前的标签。