iOS 开发中遇到的问题

1:打印的字典或者数组中的值为 unicode 编码,转为中文

 NSData *jsonData = [NSJSONSerialization dataWithJSONObject:searchType.paramasDic options:NSJSONWritingPrettyPrinted error:nil];
        NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        NSLog(@"%@",jsonStr);

2:解决UITableView系统cell分隔线起始位置

cell.separatorInset = UIEdgeInsetsMake(0, 50, 0, 0);这里的先后顺序是上左下右

3:在删除指定行的 cell 时崩溃:Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.app

 //先 remove 再 delete
                    [self.favoriteArray removeObject:f];
                    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

4:cell 自带的左滑删除要实现的方法

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath   {
    self.tableView.editing = !self.tableView.editing;

}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleDelete;

}
-(NSString*)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    return @"取消";
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

猜你喜欢

转载自blog.csdn.net/li15809284891/article/details/72628500