- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier] autorelease];
UILabel *playerHeading=[[UILabel alloc ]initWithFrame:CGRectMake(5.0f, 10.0f, 70.0f, 30.0f)];
[playerHeading setBackgroundColor:[UIColor clearColor]];
NSString *str=[NSString stringWithFormat:@"Player %i",indexPath.row];
[playerHeading setText:str];
[playerHeading setFont:[UIFont boldSystemFontOfSize:15]];
if(indexPath.section%2==0){
playerHeading.textColor=[UIColor redColor];
}
else {
playerHeading.textColor=[UIColor blueColor];
}
UITextField *txt=[[UITextField alloc]initWithFrame:CGRectMake(80.0f, 13.0f, 170.0f, 30.0f)];
[txt setBackgroundColor:[UIColor clearColor]];
//[txt setBackgroundColor:[UIColor whiteColor]];
[txt setTextColor:[UIColor grayColor]];
txt.delegate=self;
//[txt setBorderStyle:UIBorderStyle ]
[txt setText:@"Enter Player name"];
//txt.layer.cornerRadius=8.0f;
// txt.layer.masksToBounds=YES;
//txt.layer.borderColor=[[UIColor redColor]CGColor];
// txt.layer.borderWidth= 1.0f;
[cell.contentView addSubview:txt];
[cell.contentView addSubview:playerHeading];
[cell.contentView setAlpha:0.8f];
//ce]ll.textLabel.text = [listData objectAtIndex:row];
}
return cell;
}
我希望按順序顯示的數字,如球員0,玩家1,玩家2 ... 但我滾動表我以隨機格式獲得數字,如播放器1,播放器0,播放器3 請幫助如何解決此問題。
但我有動態使用的TextField,如果我嘗試添加他們如何可以獲取它們的值是一個數組,數組將有8個TextField的最大值:雖然我使用了100 – androider
你會做同樣的你的文本框但會將字符串值(而不是字段)保留在數組中,並每次更新。編輯文本字段時,獲取正在編輯的行的索引路徑,以便知道要更新的數組的哪個元素。使用 – jrturton