【发布时间】:2015-11-20 01:58:53
【问题描述】:
我正在创建一个带有两个 NSArray 的简单 tableView。第一个数组包含标题,第二个数组包含图像名称。一切正常。但是行分隔符在表格视图中的图像之后出现一些空格(参见第一个屏幕截图),而它应该没有空格出现(如第二个屏幕截图)。
我尝试了不同的方法,但遇到了同样的问题(在 iOS 8 设备上测试)。
我做错了什么?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [dataSourceArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// "Cell" is the default cell identifier in a new Master-Detail Project
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [dataSourceArray objectAtIndex:indexPath.row];
//get UIImage image Names from imageArray
cell.imageView.image=[UIImage imageNamed:[imageArray objectAtIndex:indexPath.row]];
return cell;
}
【问题讨论】:
-
谢谢。通过添加自定义子视图解决了我的问题。
标签: objective-c iphone uitableview ios8 tableviewcell