我使用下面的代碼來顯示tableview中的一些標籤和textview。但問題是一些textviews在滾動時在一些不需要的地方覆蓋。請幫幫我 。在此先感謝Sideview tableview覆蓋在iphone中的Textview
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor=[UIColor whiteColor];
if (indexPath.row==0)
{
UILabel *Sender = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 200, 20)];
[email protected]"From Time";
Sender.textColor=[UIColor colorWithRed:77.0/255.0 green:104.0/255.0 blue:159.0/255.0 alpha:1.0];
Sender.font=[UIFont fontWithName:@"verdana" size:16];
[cell addSubview:Sender];
[Sender release];
}
if (indexPath.row==1)
{
UILabel *Sender = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 200, 20)];
[email protected]"Sender";
Sender.textColor=[UIColor colorWithRed:77.0/255.0 green:104.0/255.0 blue:159.0/255.0 alpha:1.0];
Sender.font=[UIFont fontWithName:@"verdana" size:16];
[cell addSubview:Sender];
[Sender release];
UILabel *Label = [[UILabel alloc] initWithFrame:CGRectMake(30, 35, 200, 20)];
[email protected]"Achuthananthan";
Label.font=[UIFont fontWithName:@"verdana" size:14];
[cell addSubview:Label];
[Label release];
}
if (indexPath.row==2)
{
UILabel *Agenda = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 200, 20)];
[email protected]"Agenda";
Agenda.textColor=[UIColor colorWithRed:77.0/255.0 green:104.0/255.0 blue:159.0/255.0 alpha:1.0];
Agenda.font=[UIFont fontWithName:@"verdana" size:16];
[cell addSubview:Agenda];
[Agenda release];
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 30, 280, 120)];
textView.editable=NO;
textView.text=[NSString stringWithString:@"Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda."];
textView.font=[UIFont fontWithName:@"verdana" size:14];
[cell addSubview:textView];
[textView release];
}
return cell;
}
它適合你嗎? – Abhishek
不工作。謝謝 – Melbourne
是顯示單元格的內容(標籤和文本視圖)? – Abhishek