第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

動(dòng)態(tài)更改UITableView高度

動(dòng)態(tài)更改UITableView高度

慕容708150 2019-08-30 15:56:51
我想基于其單元格高度的總和從另一個(gè)viewcontroller更改tableview的高度,因?yàn)樗鼈兪莿?dòng)態(tài)的。它可能嗎?謝謝添加在:我基本上擁有一個(gè)UserProfileViewController,它在屏幕的一半上有一個(gè)容器視圖。在那里我添加了不同的其他viewcontrollers:在wall按鈕的情況下,這是我添加viewcontroller的方式,它是后續(xù)的tableview:- (IBAction)wallButtonPressed:(id)sender{    //Check if there is an instance of the viewcontroller we want to display. If not make one and set it's tableview frame to the container's view bounds    if(!_userWallViewController) {        self.userWallViewController = [[WallViewController alloc] init];//        self.userWallViewController.activityFeedTableView.frame = self.containerView.bounds;    }    [self.userWallViewController.containerView addSubview:self.userWallViewController.activityFeedTableView];    //If the currentviewcontroller adn it's view are already added to the hierarchy remove them    [self.currentViewController.view removeFromSuperview];    [self.currentViewController removeFromParentViewController];    //Add the desired viewcontroller to the currentviewcontroller    self.currentViewController = self.userWallViewController;    //Pass the data needed for the desired viewcontroller to it's instances    self.userWallViewController.searchURLString = [NSString stringWithFormat:@"event/user/%@/", self.userID];    self.userWallViewController.sendCommentURLString = [NSString stringWithFormat:@"event/message/%@", self.userID];    [self.userWallViewController.activityFeedTableView reloadData];    self.userWallViewController.totalCellHeight = ^(float totalCellHeight){在那個(gè)viewcontroller中,這是我初始化tableview的地方:-(UITableView *)activityFeedTableView{    if (!_activityFeedTableView) {        _activityFeedTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 850.0) style:UITableViewStylePlain];    }    return _activityFeedTableView;}我正在計(jì)算單元格高度的總和,問題是在調(diào)用te tableview的getter之后調(diào)用單元格的高度方法。因此,我需要某種方式來了解何時(shí)為所有細(xì)胞完成細(xì)胞的高度方法,然后我可以調(diào)整我的tableview。謝謝
查看完整描述

3 回答

?
繁星淼淼

TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超11個(gè)贊

通過xib或storyboard創(chuàng)建您的單元格。給出它的出口內(nèi)容。現(xiàn)在在CellForRowAtIndexPath中調(diào)用它。例如。如果要根據(jù)Comment的標(biāo)簽文本設(shè)置單元格高度。 在此輸入圖像描述


所以設(shè)置你的commentsLbl.numberOfLine = 0;


所以設(shè)置你的commentsLbl.numberOfLine = 0;


然后在ViewDidLoad中


 self.table.estimatedRowHeight = 44.0 ;

self.table.rowHeight = UITableViewAutomaticDimension;

現(xiàn)在


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

return UITableViewAutomaticDimension;}


查看完整回答
反對(duì) 回復(fù) 2019-08-30
?
一只斗牛犬

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超2個(gè)贊

這里的許多答案都不尊重桌子的變化或太復(fù)雜。使用autolayout時(shí),使用UITableView正確設(shè)置的子類intrinsicContentSize是一個(gè)更容易的解決方案。不需要高度限制等。


class UIDynamicTableView: UITableView

{

    override var intrinsicContentSize: CGSize {

        self.layoutIfNeeded()

        return CGSize(width: UIViewNoIntrinsicMetric, height: self.contentSize.height)

    }


    override func reloadData() {

        super.reloadData()

        self.invalidateIntrinsicContentSize()

    }

UIDynamicTableView在接口構(gòu)建器中設(shè)置TableView的類并觀察魔法,因?yàn)榇薚ableView將在調(diào)用后更改其大小reloadData()。


查看完整回答
反對(duì) 回復(fù) 2019-08-30
  • 3 回答
  • 0 關(guān)注
  • 736 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)