我正在用两个NSArrays创建一个简单的tableView。第一个数组包含标题,第二个数组包含图像名称。一切工作正常。但是行分隔符在tableview中的图像之后会出现一些空格(参见第一张截图),而它应该没有空格(如第二张截图)。桌面图像显示不正常 - iOS 8 iPhone应用程序目标C
我尝试了不同的方法,但得到同样的问题(测试的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;
}
也许这可以帮助你http://stackoverflow.com/questions/19103155/ios7-tableview-cell-imageview-extra-padding – ZHZ
感谢。我的问题是通过添加自定义子视图解决的。 –