2013-07-19 2 views
1

tableVIew 셀에 이미지를 추가하지만 표시되지 않습니다. 이미지를 버튼에 표시 할 때 조건을 사용하지만 표시하지 않습니다. 여기 TableView에서 이미지 추가 셀이 표시되지 않음

addButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    addButton.Frame=CGRectMake(590,2,42,42); 

    [addButton addTarget:self action:@selector(tab1Action:) forControlEvents:UIControlEventTouchUpInside]; 
    addButton.tag=indexPath.row; 


    NSString*test=theData.Status; 

    if ([test isEqualToString:@"1"]) { 

     [email protected]"Already Member of the group"; 



    } 

    else { 

     [email protected]""; 



     NSLog(@"Else is also Working Fine"); 




     [addButton setImage:[UIImage imageNamed:@"addbutton.png"] forState:UIControlStateNormal]; 

    } 
    addButton.clipsToBounds=YES; 
    [[cell contentView] addSubview:addButton];  

    cell.textLabel.font=[UIFont fontWithName:@"Helvetica" size:16]; 
    cell.textLabel.text=[NSString stringWithFormat:@"%@: %@",theData.GroupTitle,test]; 

    return cell; 
+0

내 포인트가 있습니까? –

답변

0

당신은 세포의 내용 없음에 추가 할 필요가 없습니다 addding 버튼의 코드입니다. 그래서 다음과 같이 할 ..

[cell addSubview:addButton]; 
+0

이것은 iphone이 아닌 ipad 버튼 – user2240329

+0

에 대한 내 편집 된 답변을 볼 수 있습니다 ... –

0

당신의 단추 프레임 CGRectMake(590,2,42,42)

frame.origin.x 화면 크기보다 너무 큰 오류입니다

640960은 자동으로 개발에만 크기 320,480에

0

// 앱의 다른 섹션에 대한 표 만들기

  • (있는 UITableViewCell *)를 tableView (jQuery과 *)를 tableView cellForRowAtIndexPath (NSIndexPath *) indexPath {

    정적는 NSString * CellIdentifier = @ "셀";

    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier : CellIdentifier];

    경우 (셀!) {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    

    }

    /* 중요 : 우리는 테이블 뷰를 다시로드 우리가 컨테이너에서 이전 뷰를 제거해야합니다 "동적 유형을"사용하는 것처럼. */

    경우 ([cell.contentView의 파단]) {위한 (UIView의 * cell.contentView의 파단]의 하위 뷰) { [하위 뷰 removeFromSuperview]; }}

    // 이미지보기 UIImageView에 iconImage * = [UIImageView에 ALLOC] INIT]의 사각형 박스를 생성; iconImage.frame = CGRectMake (12,4,53.5,53.5);

    // 셀의 레이블을 만듭니다. UILabel * cellName = [[UILabel alloc] initWithFrame : CGRectMake (75,18,200,20)]; cellName.font = [self fontForBodyTextStyle];

    NSString * cellNameStr = [NSString stringWithFormat : @ "% @", self.tableCellNames [indexPath.row]];

    // 경로 행 선택 탭 동작 switch (indexPath.행) { 경우 0

    cellName.text = cellNameStr; 
        iconImage.image = [UIImage imageNamed:@"condition.png"]; 
        [cell.contentView addSubview:iconImage]; 
        [cell.contentView addSubview:cellName]; 
    
        break; 
    
    case 1: 
        cellName.text = cellNameStr; 
        iconImage.image = [UIImage imageNamed:@"videos.png"]; 
        [cell.contentView addSubview:iconImage]; 
        [cell.contentView addSubview:cellName]; 
        break; 
    
    case 2: 
        cellName.text = cellNameStr; 
        iconImage.image = [UIImage imageNamed:@"provider.png"]; 
        [cell.contentView addSubview:iconImage]; 
        [cell.contentView addSubview:cellName]; 
        break; 
    
    case 3: 
        cellName.text = cellNameStr; 
        iconImage.image = [UIImage imageNamed:@"info.png"]; 
        [cell.contentView addSubview:iconImage]; 
        [cell.contentView addSubview:cellName]; 
        break; 
    
    default: 
        NSAssert(NO, @"Unhandled value in cellForRowAtIndexPath"); 
        break; 
    

    }

    복귀 셀; } 감사합니다. VKJ,

관련 문제