2010-12-15 8 views
1

내 응용 프로그램 탐색 기반 및보기는 UITableviewController입니다. 특정 UIViewtable 셀에 대해 ON 및 OFF 스위치 컨트롤을 추가해야합니다. 추가하는 방법.테이블 뷰 셀에 스위치를 추가하는 방법

+0

중복 가능성 검색된 -tableView:cellForRowAtIndexPath: 방법 (http://stackoverflow.com/questions/3770019/uiswitch-in-에 스위치를 추가 할 a-uitableview-cell) – Mac

답변

3

고전적으로이 질문은 이미 많이 제기되었습니다. 예를 들어 this question을 참조하십시오. 더 많은 결과를 보려면 UITableViewUISwitch을 검색하십시오.

+0

내 솔루션을 얻기 위해 샘플을 보내 주셔서 감사합니다. – SOF

3

하기 [jQuery과 셀 UISwitch]의 UITableViewDataSource Protocol

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    // Configure the cell... 
    UISwitch *aSwitch = [[[UISwitch alloc] init] autorelease]; 
    [aSwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; 
    [cell.contentView addSubview:aSwitch]; 
    return cell; 
} 
+0

스위치 컨트롤러를 추가해 주셔서 감사합니다. – SOF

관련 문제