相关疑难解决方法(0)

如何在iPhone中以编程方式增加UITableView单元格的高度?

我有单独的自定义UITableViewCell显示数据(这些数据来自服务器JSON响应).在每个UITableViewCell我有按钮阅读更多.如果用户点击阅读更多按钮我想以编程方式添加从服务器UILabel显示其他信息.但最初我设置UITableViewCell高度所以点击阅读更多按钮后,我无法看到额外的信息UILabel..

这是屏幕截图:

在此输入图像描述

这是我需要的屏幕:

在此输入图像描述

这是我使用的以下编码:

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

   int height1;
    if(readMore){
        height1=200;
        NSLog(@"Clicked");
    }
    else{
        height1=100;
        NSLog(@"Not clicked");
    }
    return height1; // Normal height
}


-(NSInteger) tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
    return [TitleArr  count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        static NSString *simpleTableIdentifier = @"SimpleTableCell_iPad";

        cell = (TableCell_Leads *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    }
    else{
        static NSString *simpleTableIdentifier …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview ios

19
推荐指数
1
解决办法
3万
查看次数

标签 统计

ios ×1

iphone ×1

objective-c ×1

uitableview ×1