나는 테이블 뷰의 액세서리로 스위치를 사용하려는 ios 앱을 만들고 있습니다. 액세서리로 UISwitch를 사용하는 방법에 대한 다음 샘플을 발견했습니다 : http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/ManageSelections/ManageSelections.html ("선택 사항에 응답"섹션 참조).액세서리로 DCRoundSwitch
내가하고 싶은 것은 텍스트를 사용자 정의 할 수 있도록 UISwitch 대신 DCRoundSwitch (https://github.com/domesticcatsoftware/DCRoundSwitch)를 사용하는 것입니다. 그러나 샘플 코드에서 제안하는 방식으로 액세서리를 만들면 라운드 손잡이가 생기고 전체 스위치를 얻지 못합니다. 나는 액세서리를 추가 사용하고 코드는 다음과 같습니다
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"PersonCell"; MyPerson *person = [self.dataController objectInListAtIndex:indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; DCRoundSwitch *switchObj = [[DCRoundSwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 20.0)]; switchObj.onText = @"in"; switchObj.offText = @"out"; [switchObj addTarget:self action:@selector(personIn:) forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)]; cell.accessoryView = switchObj; [[cell textLabel] setText:person.name]; [[cell detailTextLabel] setText:person.label]; return cell; }
내가있는 TableView 액세서리로 DCRoundSwitch 작업을 위해 무엇을 할 수 있는가?
감사합니다.
실제로 액세서리보기에 스위치를 지정하는 코드는 무엇입니까? 'cell.accessoryView = switchObj;' – charleyh
ack와 같이 복사/붙여 넣기 오류가 발생합니다. 그것을 포함하도록 업데이트 된 코드. 다행히도 일관성이 있습니다. 코드를 가지고 놀았습니다. – nojo