部分 iphone 表顶部的部分
Posted
技术标签:
【中文标题】部分 iphone 表顶部的部分【英文标题】:Section on top of section iphone table 【发布时间】:2010-06-30 16:25:12 【问题描述】:我正在构建一个分段表,它显示的部分看起来像是一个部分。您可以在图像上看到每个部分下方都有一条白线。
The image
这是我必须构建表格的代码:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
return [alertList count];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return 1;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier;
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
CellIdentifier = @"CellLandscape";
else
CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier]
autorelease];
//cell.contentView.backgroundColor = [UIColor blackColor];
CGRect frame;
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
frame.origin.x = 370;
//titleFrame.size.width = 320;
else
frame.origin.x = 220;
//titleFrame.size.width = 220;
frame.origin.y = 5;
frame.size.height = 15;
frame.size.width = 74;
UILabel *instLabel = [[UILabel alloc] initWithFrame:frame];
instLabel.tag = 1;
[cell.contentView addSubview:instLabel];
[instLabel release];
// Configure the cell.
Alert *p = [alertList objectAtIndex:indexPath.section];
UILabel *instLabel = (UILabel *) [cell.contentView viewWithTag:1];
instLabel.text = [p docDate];
instLabel.textColor = [UIColor blackColor];
[instLabel setFont:[UIFont fontWithName:@"Arial" size:12]];
NSString *path;
if ([[p subscription] isEqual:@"Y"])
path = [[NSBundle mainBundle] pathForResource:@"watchlist_on" ofType:@"png"];
else
path = [[NSBundle mainBundle] pathForResource:@"watchlist_off" ofType:@"png"];
//NSLog(@"%@", path);
cell.textLabel.textColor = [UIColor colorWithRed:.847 green:0 blue: 0 alpha: 1];
[cell.textLabel setFont:[UIFont boldSystemFontOfSize:13]];
cell.textLabel.text = [[NSString alloc] initWithFormat:@"%@", [p Name]];
cell.detailTextLabel.textColor = [UIColor blackColor];
[cell.detailTextLabel setFont:[UIFont fontWithName:@"Arial" size: 10]];
cell.detailTextLabel.text = [p docTitle];
cell.detailTextLabel.textColor = [UIColor blackColor];
[cell.detailTextLabel setFont:[UIFont fontWithName:@"Arial" size: 10]];
//cell.detailTextLabel.text = [p docDate];
//cell.imageView.image = [UIImage imageWithContentsOfFile:path];
cell.imageView.userInteractionEnabled = YES;
cell.imageView.userInteractionEnabled = YES;
//cell.imageView.image = [UIImage imageWithContentsOfFile:path];
/// [cell addSubview:imgView];
//cell.textLabel.text = [[NSString alloc] initWithFormat:@"%@, %@ G: %@\nDOB: %@ Inst: %@", [p lastName], [p firstName], [p gender],
// [p birthDate], [p inst]];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
//only 1 alert at a time
//make doc list from alert object
Document *documentList1 = [[Document alloc] init];
self.documentList = documentList1;
[documentList1 setTitle:[p docTitle]];
[documentList1 setUniqueId:[p uniqueId]];
[documentList1 setDate:[p docDate]];
[documentList1 setRepoOID:[p repoOid]];
[documentArray addObject:documentList];
return cell;
【问题讨论】:
图片链接现在失效了,让问题不太清楚。 【参考方案1】:将表格视图的分隔符样式更改为单行或无 - 您可能将其蚀刻在单行上。
【讨论】:
以上是关于部分 iphone 表顶部的部分的主要内容,如果未能解决你的问题,请参考以下文章
iPhone UITableView 与 UISearchBar 和刷新部分索引