小编Sir*_*our的帖子

UITableViewCell和UILabel

我正以这种方式UILabel向我的一部分添加两个自定义UITableView:

//in .h file:
NSArray *listaopzioni;
@property (nonatomic, retain) NSArray *listaopzioni;

//in .m file:
self.listaopzioni = [[NSArray arrayWithObjects:@"Strumenti",@"Help & Credits", nil] retain];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

    if ([indexPath section]==0) {

        cell.accessoryType = UITableViewCellAccessoryNone;

        UILabel *slogan= [[UILabel alloc] initWithFrame:CGRectMake(0,0,cell.frame.size.width,cell.frame.size.height)];
        slogan.text=[listaopzioni objectAtIndex:indexPath.row];
        slogan.textAlignment=UITextAlignmentCenter;
        slogan.font= [UIFont boldSystemFontOfSize:20];
        slogan.backgroundColor=[UIColor clearColor];
        [cell.contentView addSubview:slogan];
        [slogan release]; …
Run Code Online (Sandbox Code Playgroud)

uitableview uilabel ios

1
推荐指数
1
解决办法
4239
查看次数

标签 统计

ios ×1

uilabel ×1

uitableview ×1