无法设置表格视图的帧大小。使用xcode 4查看iphone中的控制器

时间:2011-12-01 15:42:19

标签: iphone frame tableview

我无法设置视图控制器的帧大小。表视图。这是我的视图层次的图像

enter image description here

内容视图在滚动视图中添加为子视图。我的内容视图包含标签,按钮和以编程方式添加的文本视图。

但根据我下面列出的代码,我无法设置表格视图框架&查看控制器框架。我的表视图是框架未正确设置&这就是为什么我必须向上/向下滚动才能看到我的表格单元格内容。所以我有2个卷轴,即1个用于滚动视图&表格视图为1。

这是我的代码

#define TABLE_CELL_HEIGHT 200.0f
#define ADD_VIEW_HEIGHT 30.0f

#define FONT_SIZE 24.0f
#define CELL_CONTENT_WIDTH 720.0f
#define CELL_CONTENT_MARGIN 50.0f

#define SectionHeight 50.0f

#define LEFT_MARGIN 25
#define RIGHT_MARGIN 25
#define TOP_MARGIN 35
#define BOTTOM_MARGIN 50
#define BOTTOM_FOOTER_MARGIN 32
#define DOC_WIDTH 768
#define DOC_HEIGHT 910


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSLog(@"In viewDidLoad of PostDetailsViewController");
    self.navigationItem.title = [post Title];

    [self createUserInterface];
    [self createCommentUserInterface];

    self.contentView.backgroundColor = SET_BACKGROUND_IMAGE;
    self.view.backgroundColor = SET_BACKGROUND_IMAGE;

}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [self displayCommentsForPhotoID:[post ID]];
    [self.commentsTableView reloadData];

    CGRect frame = self.commentsTableView.frame;
    frame.size.height = TABLE_CELL_HEIGHT*[commentsArray count];
    self.commentsTableView.frame = frame; 

    CGRect viewFrame = self.contentView.frame;
    viewFrame.size.height = viewFrame.size.height + (TABLE_CELL_HEIGHT*[commentsArray count]) + ADD_VIEW_HEIGHT;
    self.contentView.frame = viewFrame;

    [self.scrollView addSubview:self.contentView];
    self.scrollView.contentSize = self.contentView.bounds.size;
}



 - (void)createUserInterface {

    lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, 20.0f, 280.0f, 30.f)];
    [lblTitle setBackgroundColor:[UIColor clearColor]];
    lblTitle.text = @"Is This Fashion Post";
    [self.contentView addSubview:lblTitle];

    scrollViewForImage = [[UIScrollView alloc]initWithFrame:CGRectMake(20.0f, 60.0f, 280.0f, 200.0f)];
    scrollViewForImage.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);
    scrollViewForImage.maximumZoomScale = 4.0;
    scrollViewForImage.minimumZoomScale = 0.75;
    scrollViewForImage.clipsToBounds = YES;
    scrollViewForImage.delegate = self;
    scrollViewForImage.showsHorizontalScrollIndicator = NO;
    scrollViewForImage.showsVerticalScrollIndicator = NO;
    //scrollViewForImage.contentMode = UIViewContentModeCenter;
    scrollViewForImage.bouncesZoom = NO;
    scrollViewForImage.bounces = NO;
    //scrollViewForImage.autoresizesSubviews = YES;
    [self.contentView addSubview:scrollViewForImage];

    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 280.0f, 200.0f)];
    [self.scrollViewForImage addSubview:imageView];

    lblBy = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, 270.0f, 30.0f, 20.0f)];
    [lblBy setBackgroundColor:[UIColor clearColor]];
    lblBy.text = @"By:";
    [self.contentView addSubview:lblBy];

    lblUploaderName = [[UILabel alloc]initWithFrame:CGRectMake(60.0f, 270.0f, 200.0f, 20.0f)];
    [lblUploaderName setBackgroundColor:[UIColor clearColor]];
    [lblUploaderName setTextColor:[UIColor blueColor]];
    [lblUploaderName setUserInteractionEnabled:YES];
    UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showUserProfile)];
    [lblUploaderName addGestureRecognizer:tapRecognizer];
    [self.contentView addSubview:lblUploaderName];

    lblOn = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, 300.0f, 20.0f, 20.0f)];
    [lblOn setBackgroundColor:[UIColor clearColor]];
    lblOn.text = @"on";
    [self.contentView addSubview:lblOn];
    [lblOn release];

    lblDateTime = [[UILabel alloc]initWithFrame:CGRectMake(45.0f, 300.0f, 255.0f, 20.0f)];
    [lblDateTime setBackgroundColor:[UIColor clearColor]];
    //lblDateTime.text = @"9/11/11 11:09 AM";
    [self.contentView addSubview:lblDateTime];

    //txtViewComments = [[UITextView alloc]initWithFrame:CGRectMake(12.0f, 330.0f, 280.0f, 70.0f)];
    txtViewComments = [[UITextView alloc]initWithFrame:CGRectMake(12.0f, 325.0f, 280.0f, 70.0f)];
    //[txtViewComments setBackgroundColor:[UIColor greenColor]];
    txtViewComments.backgroundColor=[UIColor clearColor];
    [txtViewComments setEditable:NO];
    //txtViewComments.text = @"Toronto Film Festival, image from InStyle.com This is a comment on Is This Fashion";
    [txtViewComments setFont:[UIFont fontWithName:@"Helvetica" size:17.0f]];
    [self.contentView addSubview:txtViewComments];

    [txtViewComments setText:[post Comment]];

    CGRect frame = txtViewComments.frame;
    frame.size.height = txtViewComments.contentSize.height;
    txtViewComments.frame = frame;

    //newHeight = frame.size.height + 330.0f + 20.0f;
    newHeight = frame.size.height + 330.0f + 5.0f;
    NSLog(@"newHeight => %f",newHeight);

    //btnYes = [[UIButton alloc]initWithFrame:CGRectMake(20.0f, 410.0f, 60.0f, 50.0f)];
    btnYes = [[UIButton alloc]initWithFrame:CGRectMake(20.0f, newHeight, 60.0f, 50.0f)];
    [btnYes setBackgroundImage:[UIImage imageNamed:@"yes_icon.png"] forState:UIControlStateNormal];
    [btnYes setBackgroundImage:[UIImage imageNamed:@"yes_icon.png"] forState:UIControlEventTouchUpInside];
    [btnYes addTarget:self action:@selector(btnYesPressed)forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:btnYes];

    //***lblYesPercentage = [[UILabel alloc]initWithFrame:CGRectMake(80.0f, 420.0f, 50.0f, 40.0f)];
    //lblYesPercentage = [[UILabel alloc]initWithFrame:CGRectMake(80.0f, 420.0f, 70.0f, 40.0f)];
    lblYesPercentage = [[UILabel alloc]initWithFrame:CGRectMake(80.0f, newHeight, 70.0f, 40.0f)];
    [lblYesPercentage setBackgroundColor:[UIColor clearColor]];
    [lblYesPercentage setFont:[UIFont fontWithName:@"Helvetica" size:24.0f]];
    //[lblYesPercentage setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"lblYesPercentage.png"]]];
    [self.contentView addSubview:lblYesPercentage];

    //**btnNo = [[UIButton alloc]initWithFrame:CGRectMake(150.0f, 410.0f, 50.0f, 50.0f)];
    //btnNo = [[UIButton alloc]initWithFrame:CGRectMake(150.0f, 410.0f, 60.0f, 50.0f)];
    btnNo = [[UIButton alloc]initWithFrame:CGRectMake(150.0f, newHeight, 60.0f, 50.0f)];
    [btnNo setBackgroundImage:[UIImage imageNamed:@"no_icon.png"] forState:UIControlStateNormal];
    [btnNo setBackgroundImage:[UIImage imageNamed:@"no_icon.png"] forState:UIControlEventTouchUpInside];
    [btnNo addTarget:self action:@selector(btnNoPressed) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:btnNo];

    //**lblNoPercentage = [[UILabel alloc]initWithFrame:CGRectMake(210.0f, 420.0f, 50.0f, 40.0f)];
    //lblNoPercentage = [[UILabel alloc]initWithFrame:CGRectMake(220.0f, 420.0f, 70.0f, 40.0f)];
    lblNoPercentage = [[UILabel alloc]initWithFrame:CGRectMake(220.0f, newHeight, 70.0f, 40.0f)];
    [lblNoPercentage setBackgroundColor:[UIColor clearColor]];
    [lblNoPercentage setFont:[UIFont fontWithName:@"Helvetica" size:24.0f]];
    //[lblNoPercentage setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"lblNoPercentage.png"]]];
    [self.contentView addSubview:lblNoPercentage];

    //newHeight = newHeight + 70;
    newHeight = newHeight + 65;
    //lblTags = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, 480.0f, 50.0f, 20.0f)];
    lblTags = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, newHeight, 50.0f, 20.0f)];
    [lblTags setBackgroundColor:[UIColor clearColor]];
    lblTags.text = @"Tags:";
    [self.contentView addSubview:lblTags];

    //newHeight = newHeight - 10;
    newHeight = newHeight - 10;
    //txtVwTagsValue = [[UITextView alloc]initWithFrame:CGRectMake(65.0f, 470.0f, 220.0f, 90.f)];
    txtVwTagsValue = [[UITextView alloc]initWithFrame:CGRectMake(65.0f, newHeight, 220.0f, 90.f)];
    //[txtVwTagsValue setBackgroundColor:[UIColor greenColor]];
    [txtVwTagsValue setBackgroundColor:[UIColor clearColor]];
    [txtVwTagsValue setEditable:NO];
    [txtVwTagsValue setFont:[UIFont fontWithName:@"Helvetica" size:17.0f]];
    [self.contentView addSubview:txtVwTagsValue];

    [txtVwTagsValue setText:[post Tags]];

    CGRect frame1 = txtVwTagsValue.frame;
    frame1.size.height = txtVwTagsValue.contentSize.height;
    txtVwTagsValue.frame = frame1;


    [lblTitle setText:[post Title]];
    //[btnUploaderName setTitle:[post Username] forState:UIControlStateNormal];
    [lblUploaderName setText:[post Username]];
    [lblDateTime setText:[post DateAdded]];
    //[lblDateTime setText:[self returnDate:[post DateAdded]]];
    //[txtViewComments setText:[post Comment]];
    [lblYesPercentage setText:[post VoteYes]];
    [lblNoPercentage setText:[post VoteNo]];
    //[txtVwTagsValue setText:[post Tags]];

    // Format the filename
    NSString *formattedFilename = [[post Filename] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

    // display image
    NSString *url= [NSString stringWithFormat:@"%@%@",PHOTOURL,formattedFilename];

    NSLog(@"url %@",url);

    if (url !=nil) {
        // Here we use the new provided setImageWithURL: method to load the web image

        [imageView setContentMode:UIViewContentModeScaleAspectFit];
        [imageView setImageWithURL:[NSURL URLWithString:url]
                   placeholderImage:[UIImage imageNamed:@"Placeholder.png"]];
    }

}

-(void)createCommentUserInterface {

    //UILabel *lblComments = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, 570.0f, 150.0f, 30.0f)];
    //UILabel *lblComments = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, newHeight + 70.0f, 150.0f, 30.0f)];
    UILabel *lblComments = [[UILabel alloc]initWithFrame:CGRectMake(20.0f, newHeight + 45.0f, 150.0f, 30.0f)];
    [lblComments setBackgroundColor:[UIColor clearColor]];
    [lblComments setText:@"Comments"];
    [self.contentView addSubview:lblComments];

    UIButton *btnAddComment = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnAddComment addTarget:self 
                      action:@selector(btnAddCommentPressed)
            forControlEvents:UIControlEventTouchDown];

    [btnAddComment setBackgroundImage:[UIImage imageNamed:@"btn_addcomment.png"] forState:UIControlStateNormal];
    //btnAddComment.frame = CGRectMake(20.0f, 610.0f, 140.0f, 40.0f);
    //btnAddComment.frame = CGRectMake(20.0f, newHeight + 110.0f, 140.0f, 40.0f);
    btnAddComment.frame = CGRectMake(20.0f, newHeight + 80.0f, 140.0f, 40.0f);
    [self.contentView addSubview:btnAddComment];

    //commentsTableView = [[UITableView alloc]initWithFrame:CGRectMake(20.0f, 660.0f, 280.0f, 600.0f) style:UITableViewStylePlain];
    //commentsTableView = [[UITableView alloc]initWithFrame:CGRectMake(20.0f, newHeight + 160.0f, 280.0f, 600.0f) style:UITableViewStylePlain];
    commentsTableView = [[UITableView alloc]initWithFrame:CGRectMake(20.0f, newHeight + 130.0f, 280.0f, 600.0f) style:UITableViewStylePlain];
    commentsTableView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.4];
    commentsTableView.delegate = self;
    commentsTableView.dataSource = self;

    [self.contentView addSubview:commentsTableView];

}

    #pragma mark - Table view data source


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [self.commentsArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell;

    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell = nil;

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    UIColor *separatorColor = [UIColor colorWithRed:1.0/255.0 green:146.0/255.0 blue:173.0/255.0 alpha:1.0];
    [tableView setSeparatorColor:separatorColor];
    //[tableView setSeparatorColor:[UIColor darkGrayColor]];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    cell.backgroundColor = [UIColor whiteColor];
    userComment = [commentsArray objectAtIndex:[indexPath row]];

    UILabel *lblSubmittedBy = [[UILabel alloc]initWithFrame:CGRectMake(10.0f, 5.0f, 100.0f, 30.0f)];
    [lblSubmittedBy setBackgroundColor:[UIColor clearColor]];
    [lblSubmittedBy setText:@"Submitted by"];
    [cell addSubview:lblSubmittedBy];

    UIButton *btnUserName = [UIButton buttonWithType:UIButtonTypeCustom];
    btnUserName.frame = CGRectMake(120.0f, 5.0f, 150.0f, 30.0f);
    //[btnUserName setTitle:@"ITF" forState:UIControlStateNormal];
    [btnUserName setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    [btnUserName setBackgroundColor:[UIColor clearColor]];
    [btnUserName setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [btnUserName addTarget:self action:@selector(showUserProfileForUserComment:) forControlEvents:UIControlEventTouchUpInside];
    [btnUserName setUserInteractionEnabled:YES];
    [cell addSubview:btnUserName];

    UILabel *lblOnDate = [[UILabel alloc]initWithFrame:CGRectMake(10.0f, 40.0f, 20.0f, 30.0f)];
    [lblOnDate setBackgroundColor:[UIColor clearColor]];
    [lblOnDate setText:@"on"];
    [cell addSubview:lblOnDate];

    UILabel *lblDate = [[UILabel alloc]initWithFrame:CGRectMake(35.0f, 40.0f, 200.0f, 30.0f)];
    [lblDate setBackgroundColor:[UIColor clearColor]];
    [cell addSubview:lblDate];

    UITextView *txtVwComments = [[UITextView alloc]initWithFrame:CGRectMake(5.0f, 75.0f, 265.0f, 70.0f)];
    //UITextView *txtVwComments = [[UITextView alloc]initWithFrame:CGRectMake(5.0f, 75.0f, 265.0f, 0.0f)];

    [txtVwComments setBackgroundColor:[UIColor clearColor]];
    //txtVwComments.backgroundColor = cell.backgroundColor;
    [txtVwComments setFont:[UIFont fontWithName:@"Helvetica" size:17.0f]];
    [txtVwComments setEditable:NO];
    [cell addSubview:txtVwComments];

    [txtVwComments setText:[userComment Comment]];

    CGRect frame = txtVwComments.frame;
    frame.size.height = txtVwComments.contentSize.height;
    CGFloat height = frame.size.height;

    NSLog(@"Value of height => %f",height);
    txtVwComments.frame = frame;

    CGFloat ht1 = height + 20.0f + 75.0f;
    //UIButton *btnUpVote = [[UIButton alloc]initWithFrame:CGRectMake(10.0f, 160.0f, 16.0f, 16.0f)];
    UIButton *btnUpVote = [[UIButton alloc]initWithFrame:CGRectMake(10.0f, ht1 + 10.0f, 16.0f, 16.0f)];
    [btnUpVote setBackgroundColor:[UIColor clearColor]];
    [btnUpVote setBackgroundImage:[UIImage imageNamed:@"thumb_up.png"] forState:UIControlStateNormal];
    [btnUpVote addTarget:self 
                      action:@selector(btnUpVotePressed:)
            forControlEvents:UIControlEventTouchDown];
    [btnUpVote setTag:[userComment ID]];
    [cell addSubview:btnUpVote];
    NSLog(@"Value of ht1 => %f",ht1);

    lblUpVoteCount = [[UILabel alloc]initWithFrame:CGRectMake(36.0f, ht1 , 30.0f, 30.0f)];
    [lblUpVoteCount setBackgroundColor:[UIColor clearColor]];
    [lblUpVoteCount setTag:[userComment ID]];
    [cell addSubview:lblUpVoteCount];
    //NSLog(@"Value of ht2 => %f",ht2);

    //UIButton *btnDownVote = [[UIButton alloc]initWithFrame:CGRectMake(90.0f, 160.0f, 16.0f, 16.0f)];
    UIButton *btnDownVote = [[UIButton alloc]initWithFrame:CGRectMake(90.0f, ht1 + 10.0f , 16.0f, 16.0f)];
    [btnDownVote setBackgroundColor:[UIColor clearColor]];
    [btnDownVote setBackgroundImage:[UIImage imageNamed:@"thumb_down.png"] forState:UIControlStateNormal];
    [btnDownVote addTarget:self 
                    action:@selector(btnDownVotePressed:)
            forControlEvents:UIControlEventTouchDown];
    [btnDownVote setTag:[userComment ID]];
    [cell addSubview:btnDownVote];

    //lblDownVoteCount = [[UILabel alloc]initWithFrame:CGRectMake(116.0f, 150.0f, 40.0f, 30.0f)];
    lblDownVoteCount = [[UILabel alloc]initWithFrame:CGRectMake(116.0f, ht1 , 40.0f, 30.0f)];
    [lblDownVoteCount setTag:[userComment ID]];
    [lblDownVoteCount setBackgroundColor:[UIColor clearColor]];
    [cell addSubview:lblDownVoteCount];

    UIButton *btnReply = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    //btnReply = [[UIButton alloc]initWithFrame:CGRectMake(180.0f, 150.0f, 60.0f, 40.0f)];
    btnReply.frame = CGRectMake(180.0f, ht1, 60.0f, 30.0f);
    [btnReply setBackgroundColor:[UIColor clearColor]];
    [btnReply setBackgroundImage:[UIImage imageNamed:@"btn_reply.png"] forState:UIControlStateNormal];
    [btnReply addTarget:self action:@selector(btnReplyPressed:) forControlEvents:UIControlEventTouchDown];
    [btnReply setTag:[userComment ID]];
    [cell addSubview:btnReply];


    float y = ht1 + 40.0f;

    for (int i=0; i < [userComment.replyArray count]; i++) {

        if ([userComment.replyArray objectAtIndex:i] != nil) {

            UITextView *txtVwReply = [[UITextView alloc]initWithFrame:CGRectMake(5.0f, y , 265.0,0.0f )]; //70.0f)];
            //UITextView *txtVwReply = [[UITextView alloc]initWithFrame:CGRectMake(40.0f, y , 220.0,0.0f)];

            [txtVwReply setUserInteractionEnabled:NO];
            [txtVwReply setBackgroundColor:[UIColor clearColor]];
            //[txtVwReply setFont:[UIFont fontWithName:@"Helvetica" size:14.0f]];
            [txtVwReply setFont:[UIFont fontWithName:@"Helvetica" size:17.0f]];
            [cell addSubview:txtVwReply];

            commentReply = [userComment.replyArray objectAtIndex:i];


            strReply = [NSString stringWithFormat:@"Submitted by %@ \non %@\n%@",[commentReply ReplyUsername],[commentReply ReplyDateAdded],[commentReply ReplyComment]]; 
            //NSLog(@"strReply => %@",strReply);

            [txtVwReply setText:strReply];

            CGRect frame = txtVwReply.frame;
            frame.size.height = txtVwReply.contentSize.height;
            CGFloat height = frame.size.height;

            NSLog(@"Value of txtVwReply height => %f",height);
            txtVwReply.frame = frame;

            y = y + height;
            //y = y + 80;

            [txtVwReply release];

        }
    }

    [btnUserName setTitle:[userComment Username] forState:UIControlStateNormal];
    [lblDate setText:[userComment DateAdded]];
    [lblUpVoteCount setText:[NSString stringWithFormat:@"%i",[userComment UpVotes]]];
    [lblDownVoteCount setText:[NSString stringWithFormat:@"%i",[userComment DownVotes]]];

    [lblSubmittedBy release];
    //[btnUserName release];
    [lblOnDate release];
    [lblDate release];
    [txtVwComments release];
    [btnUpVote release];
    [lblUpVoteCount release];
    [btnDownVote release];
    [lblDownVoteCount release];

    return cell;
}

    #pragma mark - Table view delegate


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([commentsArray count]>0) {

        userComment = [commentsArray objectAtIndex:indexPath.row];
        NSString *strComment =userComment.Comment;
        //NSLog(@"strComment : - %@",strComment);
        NSString *strCommentReply;
        CGFloat replyHeight = 135.0f;
        if([userComment.replyArray count]>0) {
            for (int i=0; i < [userComment.replyArray count]; i++) {
                commentReply = [userComment.replyArray objectAtIndex:i];
                //NSString *
                strCommentReply = commentReply.ReplyComment;
                //NSLog(@"strCommentReply => %@",strCommentReply);
                // Append all the reply & then use to determine hight
                [strCommentReply stringByAppendingFormat:@"\n %@",strCommentReply];
                replyHeight = replyHeight + 120.0f;
            }
        }

        CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);

        CGSize sizeComment = [strComment sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];

        CGFloat height = MAX(sizeComment.height + replyHeight + 40.0f, 44.0f);

        NSLog(@"heightForRowAtIndexPath >> height %f",height);

        return height;

    }

    NSLog(@"heightForRowAtIndexPath >> TABLE_CELL_HEIGHT - %f",TABLE_CELL_HEIGHT);

    return TABLE_CELL_HEIGHT;
}

所以我需要计算表视图的框架&amp;相应地设置表视图的框架&amp;内容视图。我怎么能这样做?

这就是应用程序现在的样子

enter image description here

1 个答案:

答案 0 :(得分:1)

请注意,您的内容视图不是滚动视图的子视图。如果查看界面构建器层次结构的剪辑,则可以看到它与另一个视图位于同一级别。不过,我不知道这是否会导致你的问题。