UITableViewCell (그룹화 된) 내부에 UITextField를 넣는 방법은 무엇입니까? 나는 사용자가 그것을 편집 할 수 있기를 원한다.UITableViewCell (그룹화 된) 내부에 UITextField를 넣는 방법은 무엇입니까?
5
A
답변
5
이있는 UITableViewCell의 contentView
의 서브 뷰로 UITextField
를 추가
[mycell.contentView addSubview:view];
2
애플의 UICatalog 데모 응용 프로그램은 그룹화 된 jQuery과 셀에 UITextFields를 배치의 예를 들어 있습니다 http://developer.apple.com/iphone/library/samplecode/UICatalog/index.html
TextFieldController.m
거기에 UIKit 객체 작업을위한 다른 훌륭한 코드가 많이 있습니다.
1
이것은 내 애플리케이션에 구현 한 방법이지만 몇 가지 사항을 분명히 변경해야합니다. 희망이 도움이됩니다.
- (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.
//adding all the UITextField's to the UITableViewCell is a pain in the ass. Pretty sure this is correct though.
if ([indexPath section] == 0) {
tUser = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
tUser.adjustsFontSizeToFitWidth = YES;
tUser.textColor = [UIColor blackColor];
tPass = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
tPass.adjustsFontSizeToFitWidth = YES;
tPass.textColor = [UIColor blackColor];
if ([indexPath section] == 0) {
if ([indexPath row] == 0) {
tUser.placeholder = @"@JohnAppleseed";
tUser.keyboardType = UIKeyboardTypeEmailAddress;
tUser.returnKeyType = UIReturnKeyNext;
}
if ([indexPath row] == 1) {
tPass.placeholder = @"Required";
tPass.keyboardType = UIKeyboardTypeDefault;
tPass.returnKeyType = UIReturnKeyDone;
tPass.secureTextEntry = YES;
}
}
tUser.backgroundColor = [UIColor whiteColor];
tUser.autocorrectionType = UITextAutocorrectionTypeNo;
tUser.autocapitalizationType = UITextAutocapitalizationTypeNone;
tUser.textAlignment = UITextAlignmentLeft;
tPass.backgroundColor = [UIColor whiteColor];
tPass.autocorrectionType = UITextAutocorrectionTypeNo;
tPass.autocapitalizationType = UITextAutocapitalizationTypeNone;
tPass.textAlignment = UITextAlignmentLeft;
tUser.clearButtonMode = UITextFieldViewModeNever;
tPass.clearButtonMode = UITextFieldViewModeNever;
[tUser setEnabled:YES];
[tPass setEnabled:YES];
//[tUser release];
//[tPass release];
}
if ([indexPath section] == 0) { // Email & Password Section
if ([indexPath row] == 0) { // Email
cell.textLabel.text = @"Username";
[cell addSubview:tUser];
[tUser setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"twitter_name_preference"]];
}
else {
cell.textLabel.text = @"Password";
[cell addSubview:tPass];
[tPass setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"twitter_pass_preference"]];
}
}
return cell; }
희망이 있습니다.
관련 문제
- 1. 터치시 확장되고 uitextfield를 포함하는 사용자 정의 UITableViewCell
- 2. 내부에 UITextView가있는 UITableViewCell - 비활성화 된 경우에도 스크롤합니다!
- 3. UITableViewCell 및 그룹화 된 UITableView 이상한 동작
- 4. 그룹화 된 테이블보기에 대한 사용자 지정 UITableViewCell
- 5. UITableViewCell, 그룹화 된 스타일로 UIMenuController 표시
- 6. 메서드에서 만든 UITextField를 참조하는 방법은 무엇입니까?
- 7. UITextField를 비활성화하는 쉬운 방법은 무엇입니까?
- 8. UITableViewCell 단어 랩에서 텍스트를 만드는 방법은 무엇입니까?
- 9. 그룹화 된 테이블보기에 UISwitch를 추가하는 방법은 무엇입니까?
- 10. 그룹화 된 사용자 지정 셀에 대해 UITableViewCell 너비를 결정하는 올바른 방법은 무엇입니까?
- 11. 갤러리를 홈 화면의 위젯에 넣는 방법은 무엇입니까?
- 12. 사용자가 uitextfield를 눌렀는지 확인했는지 확인하는 방법은 무엇입니까?
- 13. 삽입 된 문서를 삽입 된 문서에 넣는 방법은 무엇입니까?
- 14. Iphone의 그룹화 된 테이블보기
- 15. 내부에 NSMutableArray도 포함 된 구조체 유형의 NSMutableArray를 작성하는 방법은 무엇입니까?
- 16. 그림자가있는 그룹화 된 uitableview
- 17. 배열에 사운드를 넣는 방법은 무엇입니까?
- 18. 지도보기에 핀을 넣는 방법은 무엇입니까?
- 19. 알림에 버튼을 넣는 방법은 무엇입니까?
- 20. 상수를 사용하지 않고 그룹화 된 UITableViewCell 콘텐츠 영역 너비를 얻는 방법
- 21. 그룹화 된 테이블보기 Obj-C
- 22. addSubview를 사용하여 동적으로 추가 된 UITextField를 사용하는 UITableViewCell - 키보드의 'return'히트시 UITextField 값 가져 오는 방법
- 23. UITextField를 특정 길이로 늘림
- 24. JQuery 플러그인 내부에 중첩 된 함수를 호출하는 방법은 무엇입니까?
- 25. asp.NET에서 GridView 내부에 중첩 된 DropDownLists를 구현하는 방법은 무엇입니까?
- 26. 그룹화 된 tableViewCell의 높이를 변경하는 방법?
- 27. UITableViewCell 이상 중복 된
- 28. 확장 된 프레임 워크 클래스에서 컨트롤러에 변수를 넣는 방법은 무엇입니까?
- 29. 게시 된 속성을 Object Inspector의 지정된 범주에 넣는 방법은 무엇입니까?
- 30. 다차원 배열의 내용을 깔끔하게 포맷 된 문자열에 넣는 방법은 무엇입니까?