2014-06-05 2 views
0

보기 컨트롤러에 두 개의 uitableviews가 있습니다. 첫 번째 테이블은 프로그래밍 방식으로 uiscrollview에 설정되고 다른 테이블은 스토리 보드에서 self.view에 설정됩니다. 두 테이블 모두 rowHeight를 45로 설정했습니다. 그러나 점차적으로 한 테이블의 높이는 내가 보여준 스크린 샷처럼 행 수가 증가함에 따라 계속 증가합니다.점차적으로 uitableview의 행 높이가 달라집니다.

scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(130, 45, self.view.frame.size.width-130, self.view.frame.size.height-45)]; 
    scrollview.backgroundColor = [UIColor colorWithRed:0.42 green:0.27 blue:0.60 alpha:1.0]; 
    tableGradeValue = [[UITableView alloc] initWithFrame:CGRectMake(0, 35, self.view.frame.size.width, self.view.frame.size.height-75) style:UITableViewStylePlain]; 
    tableGradeValue.delegate = self; 
    tableGradeValue.dataSource = self; 
    self.tableCourse.delegate = self; 
    self.tableCourse.dataSource = self; 
    tableGradeValue.rowHeight = 45; 
    scrollview.bounces = NO; 

    for(int i = 0; i< [res6Keys count]; i++) 
    { 
     CGFloat y = i * 150; 
     UILabel *lblCell = [[UILabel alloc] initWithFrame:CGRectMake(y, 1, 140, 31)]; 
     lblCell.tag = i+1; 
     [scrollview addSubview:lblCell]; 
     lblCell.backgroundColor = [UIColor clearColor]; 
     lblCell.textColor = [UIColor colorWithRed:0.93 green:0.92 blue:0.96 alpha:1.0]; 
     lblCell.text = [res6Keys objectAtIndex:i]; 
    } 
    [scrollview addSubview:tableGradeValue]; 
    scrollview.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height); 
    [self.view addSubview:scrollview]; 

을 그리고 다른있는 tableview은 일반적으로 스토리 보드에서 설정되고 rowHeight에는 45

+1

UITableview는 scrollview에서 상속되므로 스크롤보기에 넣은 이유는 무엇입니까? 정말 그걸 얻지 못했습니까?! – nikhil84

+0

scrollview의 tableview는 가로 및 세로로 스크롤 할 수 있기 때문에 테이블 뷰의 일부가 아니지만 스크롤 뷰에 계속 유지되지만 여전히 테이블과 함께 스크롤되어 MSExcel을 제공하는 맨 위의 제목 행이 있습니다 보기. –

+0

@LeoJoseph 잘못 가고있는 곳을 더 잘 이해할 수 있도록 코드를 올리시겠습니까? – z22

답변

0

난 몰라 :

Screen shot 1

Screen shot 2

코드는 다음과 같이 간다 이것이 문제였습니다. 그러나 이상하게도 나는 대답을 얻었다. 나는 스크롤바 위에있는 테이블에 @property와 @synthesis를 준다. 나는 이제 속성과 종합을 주었고 효과가있었습니다.

+0

'@ synthesis' ...? 이거 어디서 났니? – holex

+0

\ @property (강하고 비 구조) UITableView * tableGradeValue; \ @synthesize tableGradeValue; –

+0

예,'@ synthesize'와'@ synthesis'는 확실히 동일하지 않습니다. 첫 번째 키워드는 올바른 키워드이고, 두 번째 키워드는 _Objective-C_에없는 키워드입니다. – holex

관련 문제