亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

iOS 7-如何在表格視圖中顯示日期選擇器?

iOS 7-如何在表格視圖中顯示日期選擇器?

MYYA 2019-11-05 10:51:34
在WWDC 2013視頻中,Apple建議在iOS 7的表格視圖中就位顯示選擇器。如何在表格視圖單元格之間插入視圖并為其設置動畫?
查看完整描述

3 回答

?
守著一只汪

TA貢獻1872條經驗 獲得超4個贊

使用情節提要和靜態表,我可以使用以下代碼獲得相同的結果。這是一個很好的解決方案,因為如果您有許多形狀奇怪的單元格,或者想讓多個單元格動態顯示/隱藏,那么此代碼仍然可以使用。


@interface StaticTableViewController: UITableViewController


@property (weak, nonatomic) IBOutlet UITableViewCell *dateTitleCell; // cell that will open the date picker. This is linked from the story board

@property (nonatomic, assign, getter = isDateOpen) BOOL dateOpen;


@end



@implementation StaticTableViewController


-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{


    // This is the index path of the date picker cell in the static table

    if (indexPath.section == 1 && indexPath.row == 1 && !self.isDateOpen){

        return 0;

    }

    return [super tableView:tableView heightForRowAtIndexPath:indexPath];

}


-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];

    [tableView beginUpdates];

    if (cell == self.dateTitleCell){

        self.dateOpen = !self.isDateOpen;

    }

    [tableView reloadData];

    [self.tableView endUpdates];

}


查看完整回答
反對 回復 2019-11-05
  • 3 回答
  • 0 關注
  • 695 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號