私はいたるところを探していましたが、私の答えはまったく見つかりませんでした。
UITableViewにJSONの動的セルを入力し、余分なセルを非表示にしようとしています。IBでセパレーターをオフにすると、もちろんすべてのセルセパレーターが消えます。各テーブルビューセルの下部と上部に線を追加して、情報を持つセルのみに境界線が表示されるようにするにはどうすればよいですか?Quartzをインポートし、CALayerで遊んでいますが、解決策が見つかりません。
ここで同様の質問を見つけましたが、唯一の答えはあまり役に立ちませんでした。
これを行うためのより良い、異なる方法は何でしょうか?
これが私のcellForRowAtIndexPathと私のnumberOfRowsInSectionです:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
//set equal to the information in the array
return [_jsonDataArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//create Dictionary of data in row
NSDictionary *jsoninfo = [_jsonDataArray objectAtIndex:indexPath.row];
//get required keys from dictionary and assign to vairables
NSString *title = [jsoninfo objectForKey:@"title"];
NSString *subtitle = [jsoninfo objectForKey:@"subtitle"];
NSURL *imageURL = [NSURL URLWithString:[jsoninfo objectForKey:@"series_image_URL"]];
//download the images.
NSData *imgData = [NSData dataWithContentsOfURL:imageURL];
UIImage *img = [[UIImage alloc] initWithData:imgData];
//set boarder for custom cells... I need to have a border on the top and bottom of the cells I am creating so xcode does not autofill the empty space.
//fill in text to cells
cell.textLabel.text = title;
cell.detailTextLabel.text = subtitle;
cell.imageView.image = img;
return cell;
}