将图像放在桌面视图iphone上

时间:2011-04-20 07:00:38

标签: objective-c xcode

我有三行以编程方式配置。我想只将图像放在表视图的第一行。图像必须覆盖整个第一行(默认情况下不在表格视图单元格的左侧)

这是我的代码:

- (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
 {
switch (indexPath.row)
{
    case 1:

if(indexPath.row==1)
    {
    return 230.0; // first row is 123px high
    }
        default:
            return 100.0; // all other rows are 40px high 
    }
}
-(void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {

            case 0:
            break;      

        case 1:
            if (indexPath.row==1) {

                UIButton *button1=[UIButton buttonWithType:UIButtonTypeRoundedRect];
                [button1 setFrame:CGRectMake(5, 10, 310, 40)];
                [button1 setTitle:@"Give" forState:UIControlStateNormal];
                [button1 addTarget:self action:@selector(give)
                 forControlEvents:UIControlEventTouchUpInside];

                [button1.titleLabel setFont:[UIFont boldSystemFontOfSize:15]];
                [button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [cell.contentView addSubview:button1];



                UIButton *button2=[UIButton buttonWithType:UIButtonTypeRoundedRect];
                [button2 setFrame:CGRectMake(5, 60, 310, 40)];
                [button2 setTitle:@"YouTube" forState:UIControlStateNormal];
                [button2 addTarget:self action:@selector(Announcements)
                 forControlEvents:UIControlEventTouchUpInside];

                [button2.titleLabel setFont:[UIFont boldSystemFontOfSize:15]];
                [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [cell.contentView addSubview:button2];


                UIButton *button3=[UIButton buttonWithType:UIButtonTypeRoundedRect];
                [button3 setFrame:CGRectMake(5, 110, 310, 40)];
                [button3 setTitle:@"Follow us on Twitter" forState:UIControlStateNormal];
                [button3 addTarget:self action:@selector(Twitter)
                 forControlEvents:UIControlEventTouchUpInside];

                [button3.titleLabel setFont:[UIFont boldSystemFontOfSize:15]];
                [button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [cell.contentView addSubview:button3];

                UIButton *button4=[UIButton buttonWithType:UIButtonTypeRoundedRect];
                [button4 setFrame:CGRectMake(5, 160, 310, 40)];
                [button4 setTitle:@"Follow us on FaceBook" forState:UIControlStateNormal];
                [button4 addTarget:self action:@selector(Facebook)
                 forControlEvents:UIControlEventTouchUpInside];

                [button4.titleLabel setFont:[UIFont boldSystemFontOfSize:15]];
                [button4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

                [cell.contentView addSubview:button4];

                /*[button1 release];
                [button2 release];
                [button3 release];
                [button4 release];*/

            }
            break;
        default:
            break;
    }
    }

1 个答案:

答案 0 :(得分:2)

您可以在内容视图中添加UIImageView。