- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell==nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; SpentMoney *spentMoney = [dailyContent objectAtIndex:indexPath.row]; NSDateFormatter *dateformat = [[NSDateFormatter alloc]init]; dateformat.dateFormat = @"HH:mm:ss"; cell.textLabel.text = [dateformat stringFromDate: spentMoney.spentDate]; cell.detailTextLabel.text = [NSString stringWithFormat:@"$%@",spentMoney.money]; //圖片存至資料庫時是用NSData,讀取也只要用imageWithData把圖片讀取出來 cell.imageView.image = [UIImage imageWithData:spentMoney.contentImage]; return cell; dateformat = nil; } |