UITableViewCell ----- Cell視圖和文件的刪除

  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

pragma tableView--delegate

pragma tableView

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.arrayData.count;
}

  • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    return 87;
    }

  • (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {
    UIView *view =[[ UIView alloc] init];
    view.backgroundColor = [UIColor colorWithRed:0.16 green:0.17 blue:0.21 alpha:0.2];
    return view;
    }

  • (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
    {
    return 0.5;
    }

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"PDFTableViewCell";
KGCBaikePDF *model = [self.arrayData objectAtIndex:indexPath.row];
PDFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil) {
NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"PDFTableViewCell" owner:nil options:nil];
cell = [nibs lastObject];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
[cell KGCBaikePDFload:model];
return cell;
}

  • (BOOL)tableView: (UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;
    }

  • (BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
    return YES;
    }

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

KGCBaikePDF *model = [self.arrayData objectAtIndex:indexPath.row];
[self.arrayData removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]  withRowAnimation:UITableViewRowAnimationRight];
[tableView setEditing:NO animated:YES];
[self cleanDownloadFiles:model.strName];
//刪除數(shù)據(jù)庫
[BaiDataBase jq_inDatabase:^{
    NSString *sql = [NSString stringWithFormat:@"where strName = '%@'",model.strName];
    [BaiDataBase jq_deleteTable:KGCNAMEPDF whereFormat:sql];
}];
[self initData];

}

  • (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    return @"刪除";
    }

//清空可以根據(jù)這個去清空
-(void)cleanDownloadFiles:(NSString *)file
{
NSString *full = [[self cachesDirectory] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.pdf",[self transform:file]]];
NSFileManager *fileManager = [[NSFileManager alloc] init];
if ([fileManager fileExistsAtPath:full]) {
NSError *removeError = nil;
if ([fileManager removeItemAtPath:full error:&removeError]) {
[self.view showToastMessage:@"刪除完成"];
}
if (removeError)
{
[self.view showToastMessage:@"刪除失敗"];
}
}
}

//獲取文件的位置 沙盒
-(NSString *)cachesDirectory
{
return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0] stringByAppendingPathComponent:[PersonInfo getPersonInfo].passport];
}

  • (NSString *)transform:(NSString *)chinese
    {
    NSMutableString *pinyin = [chinese mutableCopy];
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripCombiningMarks, NO);
    return [pinyin uppercaseString];
    }

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    }
    */

@end

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末矾利,一起剝皮案震驚了整個濱河市姑裂,隨后出現(xiàn)的幾起案子男旗,更是在濱河造成了極大的恐慌,老刑警劉巖察皇,帶你破解...
    沈念sama閱讀 218,036評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件茴厉,死亡現(xiàn)場離奇詭異,居然都是意外死亡什荣,警方通過查閱死者的電腦和手機(jī)矾缓,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,046評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來稻爬,“玉大人嗜闻,你說我怎么就攤上這事∥Τ” “怎么了琉雳?”我有些...
    開封第一講書人閱讀 164,411評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長竞滓。 經(jīng)常有香客問我咐吼,道長,這世上最難降的妖魔是什么商佑? 我笑而不...
    開封第一講書人閱讀 58,622評論 1 293
  • 正文 為了忘掉前任锯茄,我火速辦了婚禮,結(jié)果婚禮上茶没,老公的妹妹穿的比我還像新娘肌幽。我一直安慰自己,他們只是感情好抓半,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,661評論 6 392
  • 文/花漫 我一把揭開白布喂急。 她就那樣靜靜地躺著,像睡著了一般笛求。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上探入,一...
    開封第一講書人閱讀 51,521評論 1 304
  • 那天狡孔,我揣著相機(jī)與錄音蜂嗽,去河邊找鬼。 笑死植旧,一個胖子當(dāng)著我的面吹牛辱揭,可吹牛的內(nèi)容都是我干的离唐。 我是一名探鬼主播,決...
    沈念sama閱讀 40,288評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼亥鬓,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了泡躯?” 一聲冷哼從身側(cè)響起贮竟,我...
    開封第一講書人閱讀 39,200評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎较剃,沒想到半個月后咕别,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,644評論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡写穴,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,837評論 3 336
  • 正文 我和宋清朗相戀三年惰拱,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片偿短。...
    茶點(diǎn)故事閱讀 39,953評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡昔逗,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出勾怒,到底是詐尸還是另有隱情笔链,我是刑警寧澤腮猖,帶...
    沈念sama閱讀 35,673評論 5 346
  • 正文 年R本政府宣布澈缺,位于F島的核電站,受9級特大地震影響误堡,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜陪踩,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,281評論 3 329
  • 文/蒙蒙 一悉抵、第九天 我趴在偏房一處隱蔽的房頂上張望姥饰。 院中可真熱鬧孝治,春花似錦、人聲如沸岂座。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,889評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至稿黍,卻和暖如春崩哩,著一層夾襖步出監(jiān)牢的瞬間琢锋,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,011評論 1 269
  • 我被黑心中介騙來泰國打工钉嘹, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留跋涣,地道東北人鸟悴。 一個月前我還...
    沈念sama閱讀 48,119評論 3 370
  • 正文 我出身青樓细诸,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子利赋,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,901評論 2 355

推薦閱讀更多精彩內(nèi)容