我正在创建一个应用程序,我必须将一个单元分成三部分。例如,我必须在一个单元格中给出标题,并在下面显示相应的数据。将`UITableViewCell`分成几部分
我该怎么做?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
myappAppDelegate *mydelegate=(myappAppDelegate *)[[UIApplication sharedApplication]delegate];
database *objdata =[mydelegate.myarray objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
if (indexPath.row == 0)
{
UILabel *temp = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 200, 44)];
temp.text [email protected]"Main Balance";
temp.backgroundColor = [UIColor clearColor];
temp.font = [UIFont systemFontOfSize:19];
[cell addSubview:temp];
UILabel *temp1 = [[UILabel alloc] initWithFrame:CGRectMake(240, 0, 50, 44)];
temp1.text [email protected]"2000";
temp1.backgroundColor = [UIColor clearColor];
temp1.font = [UIFont systemFontOfSize:19];
[cell addSubview:temp1];
else if(indexPath.row==1)
{
UILabel *temp = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 108, 44)];
temp.text [email protected]"Income";
temp.backgroundColor = [UIColor clearColor];
temp.font = [UIFont systemFontOfSize:19];
[cell addSubview:temp];
}
else
{
UILabel *temp = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 108, 44)];
temp.text =[NSString stringWithFormat:@"%d",objdata.amount];
temp.backgroundColor = [UIColor clearColor];
temp.font = [UIFont systemFontOfSize:19];
[cell addSubview:temp];
}
enter code here
在主屏幕上创建一个主Blaance文本框和两个按钮一样的收入,费用和最后一个显示按钮。当我点击收入时,它会显示另一个视图,其中添加收入的文本框和一个按钮添加到主balance.I键入收入金额在该文本框中,然后单击保存,它将保存在数据库中,我做同样的费用,然后点击添加到主余额按钮,它将被添加或减去主屏幕上显示的主余额文本框中的金额。然后单击主屏幕上的最终显示按钮,它将显示三个标签收入,费用,主平衡..在TableView.I获得收入和费用下的价值但它仅显示我在数据库中输入的初始值在设计时按查询。
我的问题: -想我加4个数据,那么最终显示将显示,即使我添加更多的数据是在最终显示器还显示所有数据....我希望你能得到我的point..please引导我我很困惑。
u能张贴代码,请。 – 2012-02-09 12:12:41
UILabel * temp2 = [[UILabel alloc] initWithFrame:CGRectMake(109,0,106,44)]; temp2.text = @“temp2”; temp2.backgroundColor = [UIColor clearColor]; [cell addSubview:temp2] – 2012-02-09 12:16:36
: - 我喜欢上面的代码 – 2012-02-09 12:17:10