[obj-c] UITableView

iPhone 2012. 11. 20. 11:53

UITableView



contentOffset : content의 처음부터 현재 위치한 곳까지의 거리

contentSize : 테이블뷰가 가진 컨텐츠의 거리







** (CGFloat)tableView:heightForRowAtIndexPath는 (UITableViewCell *)cellForRowAtIndexPath보다 빨리 불린다.




셀을 선택했을 때, Hightlight color 없애기


cell.selectionStyle = UITableViewCellSelectionStyleNone;






indexPath로 현재셀 얻기



 [self tableView:tableView cellForRowAtIndexPath:indexPath];






셀안에 이미지 넣기 



>>> tableView:cellForRowAtIndexPath 안에서


NSString *imagePath = @"image.jpg";     

cell.image = [UIImage imageNamed:imagePath]; 






구분선 없애기



tableView.separatorStyle = UITableViewCellSeparatorStyleNone;





셀이 각각 다른 높이를 가질 때


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath









스크롤 한후, 테이블 상단과 셀의 위치 맞춰주기


- (void)scrollViewDidEndDecelerating:(UITableView *)tableView {

    int tomove = ((int)tableView.contentOffset.y%(int)tableView.rowHeight);

    

    if(tomove < tableView.rowHeight/2){

        [tableView setContentOffset:CGPointMake(0, tableView.contentOffset.y-tomove) animated:YES];

    }else{

        [tableView setContentOffset:CGPointMake(0, tableView.contentOffset.y+(tableView.rowHeight-tomove)) animated:YES];

    }

    

}


- (void)scrollViewDidEndDragging:(UITableView *)scrollView willDecelerate:(BOOL)decelerate {

    if(decelerate) return;

    [self scrollViewDidEndDecelerating:scrollView];

}




드래그로 페이징







바운드 영역을 바꿈

tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f); //첫번째 값을 바꾸면 y축의 바운드영역이 바뀜




Posted by tenn
,