我有酥料餅的屏幕,裏面坐了:的UITableViewCell變得反應遲鈍
- 的標籤,可能會或可能不會出現(標題)
- 一個搜索欄,可能會或可能不會出現
- 一個可能或可能不會出現的標籤,並且具有可變高度(幫助標籤)
- 滾動視圖,其可能會或可能不會出現,並且具有可變高度(關於下表的一些信息)
- 表查看
爲了呈現一些不錯的東西,在viewDidLoad
中,我移動了各種幀以正確放置對象,並且沒有未使用的空間讓我的彈出窗口混亂。此外,我然後調整表格(以獲取最需要的位置),並通過contentSizeInPopover
(避免出現近乎空的巨大彈出窗口)彈出窗口。所有調整大小似乎很好,但我有一個大問題:所有調整大小完成後,我的UITableView的一些單元格變得沒有響應。一個或兩個單元格,通常是第二個單元格,只在我點擊它們的外角時纔會做出響應,但單元格的其餘部分完全忽略了任何觸摸。
我試過一切:全部移動到viewWillAppear
,讓autoresize完成它的工作(似乎也沒有工作),但我每次都會遇到這個問題。我發現,如果我評論涉及更改表格的frame
或contentSizeInPopover
中的問題時遇到的問題,問題就會停止,但隨後我的觀點就會混亂,所以這不是一個解決辦法。
如果有人可以給我一些東西擺脫這個混亂,那將是非常棒的。
- (CGFloat)getHeightWithoutTable { return LIST_TITLE_HEIGHT + (self.searchBar.hidden ? 0 : LIST_SEARCH_BAR_HEIGHT) + (self.helpLabel.hidden ? 0 : self.helpLabel.frame.size.height + LIST_STD_SPACE) + (self.errorScrollView.hidden ? 0 : self.errorScrollView.frame.size.height + LIST_STD_SPACE); } -(void)viewDidLoad { [super viewDidLoad]; self.tableViewOutlet.backgroundView = nil; self.originData = [NSMutableArray array]; self.searchedData = [NSMutableArray array]; if (self.helper != nil) { CGFloat heightOffset = 0; // Content self.originData = [self.helper getData]; self.tableData = [NSMutableArray arrayWithArray:self.originData]; // Title NSString *title = [self.helper getPopoverTitle]; if (title == nil) { self.popoverTitle.hidden = YES; heightOffset -= LIST_TITLE_HEIGHT; } else { self.popoverTitle.text = [self.helper getPopoverTitle]; } // Search if ([self.originData count] [self getStdHeight]/3){ self.helpLabel.lineBreakMode = UILineBreakModeTailTruncation; [self.helpLabel sizeThatFits:CGSizeMake(self.helpLabel.frame.size.width, [self getStdHeight]/3)]; } heightOffset += (self.helpLabel.frame.size.height - LIST_HELP_STD_HEIGHT); } // Errors if ([self.helper respondsToSelector:@selector(getErrors)]) { self.errors = [self.helper getErrors]; } if (self.errors == nil || [self.errors count] == 0) { self.errorScrollView.hidden = YES; self.errorBg.hidden = YES; heightOffset -= LIST_ERROR_STD_HEIGHT + LIST_STD_SPACE; } else { [self createErrorView]; heightOffset += (self.errorScrollView.frame.size.height - LIST_ERROR_STD_HEIGHT); } // Table CGFloat previewHeight = LIST_CELL_HEIGHT * [self.tableData count] + LIST_STD_SPACE; CGFloat remainingHeight = LIST_MAX_HEIGHT - [self getHeightWithoutTable] - LIST_STD_SPACE; CGFloat tableHeight = MIN(previewHeight, remainingHeight); CGRect tableFrame = self.tableViewOutlet.frame; self.tableViewOutlet.frame = CGRectMake(tableFrame.origin.x, tableFrame.origin.y + heightOffset, LIST_WIDTH, tableHeight); // Selected items if ([helper getSelectedObject] != nil){ int index = [self.tableData indexOfObject:[helper getSelectedObject]]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0]; [self.tableViewOutlet scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; } } } - (CGSize)contentSizeForViewInPopover { if (self.navigationController) { return CGSizeMake(LIST_WIDTH, LIST_MAX_HEIGHT); } else { CGFloat totalHeight = [self getHeightWithoutTable] + self.tableViewOutlet.frame.size.height + LIST_STD_SPACE; return CGSizeMake(LIST_WIDTH, totalHeight); } }
(gist如果你需要一些色彩來幫助你)
筆尖的圖像:因爲你沒有提供
只需添加代碼和圖像 – 2012-03-14 16:42:04