[英]UITableViewCell's Accessory View Button is not displaying in ipad portrait mode
我是ios新手,如果發現錯誤,請指導我。 這是我的情況。 UITableViewCell正在顯示標簽和按鈕。 僅當選擇單元格時,按鈕才應出現。 有時,如果標簽文本很大,它們都會重疊。 因此決定將按鈕添加為附件視圖。 在iPhone中,向UITableViewCell的“附件視圖”添加按鈕正在工作。 按鈕僅在iPad橫向模式下顯示,在iPad縱向模式下不顯示按鈕。 我錯過了什么。 有沒有人發現類似的東西。
- (void)tableView:(UITableView *)tview didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tview cellForRowAtIndexPath:indexPath];
cell.accessoryView = joinButton;
}
- (void)tableView:(UITableView *)tView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tView cellForRowAtIndexPath:indexPath];
cell.accessoryView = nil;
}
- (void)viewDidLoad{
NSString *joinLabel = NSLocalizedString(@"Join", @"");
self.joinButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[joinButton setTitle:joinLabel forState:UIControlStateNormal];
/* set join button frame **/
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (cell.isSelected) {
cell.accessoryView = joinButton; // No reason to create a new one every time, right?
}
else {
cell.accessoryView = nil;
}
}
僅當連接按鈕已經以橫向模式顯示時,它才以縱向模式顯示聯接按鈕,然后將旋轉從橫向更改為縱向。 再次單擊其他某個單元格不會在該特定所選單元格上顯示按鈕。 理想情況下,每次在雙向模式下單擊單元格時,它都應顯示按鈕。
謝謝
您是否正在重新加載旋轉的表格視圖?
您已經在didSelectRowAtIndexPath中完成了(cell.accessoryView = joinButton;)的編碼,而不是在UITableViewDataSource的cellForRowAtIndexPath中或UITableViewDelegate的willDisplayCell中進行了編碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.