标签:
1.使用FMDB处理常量变量数据时,必须要把数据封装成对象,否则程序会崩溃报错。例如我想把一个BOOL值存进数据库时,需要做这些操作:
-(BOOL) insertNewModelDataToDatabase:(flower *)flower { FMDatabase *db = [FMDatabase databaseWithPath:self.databasePath]; if(![db open]) return NO; int isNotification = (flower.needNotification)? 1:0; BOOL success = [db executeUpdate:@"INSERT INTO flowers (name, soil, date, time, pic, noti) VALUES (?, ?, ?, ?, ?, ?)", flower.name, flower.soil, flower.date, flower.time, flower.pic, [NSNumber numberWithInt:isNotification]]; [db close]; if (!success) NSLog(@"%@", [db lastErrorMessage]); return YES; }
2.如何消除UITableviewCell的分割线的空白,添加以下代码:
#pragma mark 显示完整分割线(消除左空白) - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { [cell setSeparatorInset:UIEdgeInsetsZero]; } if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { [cell setLayoutMargins:UIEdgeInsetsZero]; } } - (void)viewDidLayoutSubviews { if ([self.detailTableView respondsToSelector:@selector(setSeparatorInset:)]) { [self.detailTableView setSeparatorInset:UIEdgeInsetsZero]; } if ([self.detailTableView respondsToSelector:@selector(setLayoutMargins:)]) { [self.detailTableView setLayoutMargins:UIEdgeInsetsZero]; } }
标签:
原文地址:http://www.cnblogs.com/mysaya/p/4612625.html