我的UITableView有2個定製單元:小區1小區2 &的UITableViewCell重排序控制表時滾動消失
我的UITableView顯示的一個或另一個根據枚舉值。
如果enumValue == 0,小區1所示,並表不應該允許重新排序 如果enumValue> 0,顯示小區2和表應該允許重新排序
所有這一切工作正常。重排序控件在枚舉值更改時適當地顯示。
我的問題:當重排序控件出現在單元格上時,當行滾動出視圖時它們將消失。這是爲什麼發生?
對不起,關於格式和粗略的代碼。我沒有問題的網站。任何明顯突出的東西都可能導致這種情況?
> // enum
>
> -(void)setScorePhase:(phase)scorePhase {
>
> _scorePhase = scorePhase;
>
> if (scorePhase > score) {
> self.btnPrevious.hidden = NO;
> [self.tableCorps setEditing:YES animated:YES];
> } else {
> self.btnPrevious.hidden = YES;
> [self.tableCorps setEditing:NO animated:YES];
> }
>
> switch (scorePhase) {
> case score:
> self.lblInstructions.text = @"Give your scores";
> self.btnNext.titleLabel.text = @"Next";
> break;
> case bestdrums:
> self.lblInstructions.text = @"Order the corps by best percussion";
> self.btnNext.titleLabel.text = @"Next";
> break;
> case besthornline:
> self.lblInstructions.text = @"Order the corps by best hornline";
> self.btnNext.titleLabel.text = @"Next";
> break;
> case bestguard:
> self.lblInstructions.text = @"Order the corps by best colorguard";
> self.btnNext.titleLabel.text = @"Next";
> break;
> case loudesthornline:
> self.lblInstructions.text = @"Order the corps by loudest hornline";
> self.btnNext.titleLabel.text = @"Next";
> break;
> case favorite:
> self.lblInstructions.text = @"Order the corps by your favorite";
> self.btnNext.titleLabel.text = @"Submit";
> break;
>
> default:
> self.lblInstructions.text = @"Error";
> break;
> }
> [self.tableCorps reloadData];
}
>
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
>
> return 2;
> }
>
> -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
>
> switch (section) {
> case 0: return @"World Class";
> case 1: return @"Open Class";
> default: return @"Error";
> }
> }
>
> - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
>
> if ([self.arrayOfPerformingCorps count]) {
> switch (section) {
> case 0: return [self.arrayOfWorldClass count];
> case 1: return [self.arrayOfOpenClass count];
> default: return 0;
> }
> } else {
> return 0;
> }
> }
>
> -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
>
> UITableViewCell *cell;
> if (self.scorePhase == score) {
> cell = [self.tableCorps dequeueReusableCellWithIdentifier:@"cell1"];
>cell.showsReorderControl = NO;
>
> } else {
> cell = [self.tableCorps dequeueReusableCellWithIdentifier:@"cell2"];
>cell.showsReorderControl = YES;
>
> }
>
>
> PFObject *corps;
> if ([self.arrayOfPerformingCorps count]) {
> if ((int)[indexPath section] == 0) {
> corps = [self.arrayOfWorldClass objectAtIndex:[indexPath row]];
> } else {
> corps = [self.arrayOfOpenClass objectAtIndex:[indexPath row]];
> }
>
> UILabel *corpsNameLabel = (UILabel *)[cell viewWithTag:0];
> corpsNameLabel.text = corps[@"corpsName"];
>
>
> } else {
> //cell.textLabel.text = @"";
> //cell.detailTextLabel.text = @"";
> }
>
> return cell;
> }
>
> #pragma mark - Table Reordering
> - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
> if (self.scorePhase > score) return YES;
> else return NO;
> }
> - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
> return UITableViewCellEditingStyleNone;
> }
> - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
> return NO;
> }
> - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
> return YES;
> }
> - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath
> toIndexPath:(NSIndexPath *)destinationIndexPath{
>
> }
>
> - (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath
> *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
> {
> if (sourceIndexPath.section != proposedDestinationIndexPath.section) {
> NSInteger row = 0;
> if (sourceIndexPath.section < proposedDestinationIndexPath.section) {
> row = [tableView numberOfRowsInSection:sourceIndexPath.section] - 1;
> }
> return [NSIndexPath indexPathForRow:row inSection:sourceIndexPath.section];
> }
>
> return proposedDestinationIndexPath;
> }
經過進一步測試,我認爲這是一個iOS 8測試版問題。 –
我也面臨同樣的問題。我傾向於相信它與iOS 8測試版的問題。 – cybervedaa