第二个视图上的 UILabel 仅更新一次

发布于 2024-10-17 09:02:58 字数 1624 浏览 1 评论 0原文

我有一个 tableView,单击单元格后,tableView 会调整大小,并且第二个视图会滑入视图。第二个视图包含有关所选记录的更多信息...

非工作代码

if(frame.size.height > 600)
{

    CGRect detailFrame = StudyDetailView.view.frame;

    self.tableview.autoresizingMask = UIViewAutoresizingNone;
    detailFrame.origin.y = (frame.size.height-200);
    detailFrame.size.height = 200;
    [self.view addSubview:StudyDetailView.view];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.7];
        self.tableview.frame = CGRectMake(0,0,frame.size.width,frame.size.height-200);
    [UIView commitAnimations];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.2];   
        StudyDetailView.view.frame = detailFrame;
    [UIView commitAnimations];
}

    StudyDetailView.ImageCount.text = [NSString stringWithFormat:@"%@", [[StudyListData objectAtIndex:indexPath.row] image_count]];
    [StudyDetailView.SeriesCount setText:[NSString stringWithFormat:@"%@", [[StudyListData objectAtIndex:indexPath.row] series_count]]];
    NSLog(@"This right after the view is set.. right?: %@",[NSString stringWithFormat:@"%@", [[StudyListData objectAtIndex:indexPath.row] series_count]]);

}

ImageCount 标签(在第二个视图上)仅更新一次,而 NSLog 继续显示正确​​的值..

任何建议?

工作代码

CGRect frame = self.tableview.frame;
if(StudyDetailView == nil)
{
    StudyDetailView = [[StudyListDetailController alloc] initWithNibName:@"StudyListDetailController" bundle:nil];
    [self.view addSubview:StudyDetailView.view];
}
if(frame.size.height > 600)
.......

I have a tableView, that upon clicking a cell, the tableView is resized and a second view slides into view. The second view contains more information about the selected record...

NON-WORKING CODE

if(frame.size.height > 600)
{

    CGRect detailFrame = StudyDetailView.view.frame;

    self.tableview.autoresizingMask = UIViewAutoresizingNone;
    detailFrame.origin.y = (frame.size.height-200);
    detailFrame.size.height = 200;
    [self.view addSubview:StudyDetailView.view];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.7];
        self.tableview.frame = CGRectMake(0,0,frame.size.width,frame.size.height-200);
    [UIView commitAnimations];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.2];   
        StudyDetailView.view.frame = detailFrame;
    [UIView commitAnimations];
}

    StudyDetailView.ImageCount.text = [NSString stringWithFormat:@"%@", [[StudyListData objectAtIndex:indexPath.row] image_count]];
    [StudyDetailView.SeriesCount setText:[NSString stringWithFormat:@"%@", [[StudyListData objectAtIndex:indexPath.row] series_count]]];
    NSLog(@"This right after the view is set.. right?: %@",[NSString stringWithFormat:@"%@", [[StudyListData objectAtIndex:indexPath.row] series_count]]);

}

The ImageCount label (on the second view) only updates once, while the NSLog continues to show the correct values..

any suggestions?

WORKING CODE

CGRect frame = self.tableview.frame;
if(StudyDetailView == nil)
{
    StudyDetailView = [[StudyListDetailController alloc] initWithNibName:@"StudyListDetailController" bundle:nil];
    [self.view addSubview:StudyDetailView.view];
}
if(frame.size.height > 600)
.......

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月静好 2024-10-24 09:02:58
 cell.clearsContextBeforeDrawing = YES; 

试试这个看看是否有效。如果没有,请提供更多详细信息,例如在 UIlable 中写入文本的函数

 cell.clearsContextBeforeDrawing = YES; 

try this see if it works. If not please give more details like the functions where you write the text in the UIlable

若能看破又如何 2024-10-24 09:02:58

您已经创建了一个自定义类 StudyDetailView,您在其中添加了两个标签并设置了它们的属性。我认为 StudyDetailView 类有问题。
上面写的代码没有问题。

您可以发布您的代码来解决问题吗?

You have created a custom class StudyDetailView Where you had added two labels and made their properties. I think there's something wrong in StudyDetailView class.
There's no problem in the above written code.

Can you post your code for figuring out the problem?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文