Tôi đã tạo chế độ xem bảng trong ứng dụng iPhone bằng Trình tạo giao diện (IB). Kiểu bảng của tôi được đặt thành Nhóm và hiển thị theo cách đó trong IB. Tuy nhiên, bất cứ khi nào tôi xây dựng và chạy, nó sẽ hiển thị như một kiểu Plain trong trình mô phỏng.Cài đặt kiểu nhóm không có hiệu lực từ IB, UITableView
Tôi có một chế độ xem khác được đặt thành Nhóm và không gặp sự cố này. Có ai gặp vấn đề này trước đây không?
Phần còn lại của chế độ xem không được tạo theo chương trình, vì vậy, tôi muốn tránh làm điều đó cho chế độ xem này. Phải có một cái gì đó tôi đang mất tích.
Phương pháp tableView duy nhất tôi đang làm nhiều bất cứ điều gì trong là phương pháp xử lý ô, nơi tôi đang kết hợp với một hộp văn bản vào các lĩnh vực chọn:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
if (indexPath.section == 0) {
if (indexPath.row == 0) {
cell.textLabel.text = @"Title";
UITextField *listTitleTextField = [ [ UITextField alloc ] initWithFrame: CGRectMake(150, 10, 145, 38) ];
listTitleTextField.adjustsFontSizeToFitWidth = YES;
listTitleTextField.textColor = [UIColor blackColor];
listTitleTextField.font = [UIFont systemFontOfSize:17.0];
listTitleTextField.placeholder = @"Your Title";
listTitleTextField.backgroundColor = [UIColor whiteColor];
listTitleTextField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
listTitleTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; // no auto capitalization support
listTitleTextField.textAlignment = UITextAlignmentRight;
listTitleTextField.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard)
listTitleTextField.returnKeyType = UIReturnKeyDone;
listTitleTextField.tag = 0;
listTitleTextField.delegate = self;
listTitleTextField.clearButtonMode = UITextFieldViewModeUnlessEditing; // no clear 'x' button to the right
if (self.wishList.listTitle == nil || [self.wishList.listTitle length] == 0) {
listTitleTextField.text = @"";
}
else {
listTitleTextField.text = self.wishList.listTitle;
}
[listTitleTextField setEnabled: YES ];
[cell addSubview: listTitleTextField ];
[listTitleTextField release];
}
else if (indexPath.row == 1) {
cell.detailTextLabel.text = @"Pick an Icon";
cell.textLabel.text = @"List Icon";
}
}
else {
cell.textLabel.text = @"Add Wish";
}
return cell;
}
Đăng mã của bạn? –
Không thực sự bất kỳ mã chương trình nào để đăng là vấn đề, đặt Kiểu thành "được nhóm" trong IB, sau đó chỉ cần thực hiện các phương thức I/F thường lệ để đặt tên phần và sửa đổi ô bảng khi cần để hiển thị giá trị. –
Bạn có sử dụng kết hợp này với UITabBarController không? – JamesSugrue