第二个视图上的 UILabel 仅更新一次
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个看看是否有效。如果没有,请提供更多详细信息,例如在 UIlable 中写入文本的函数
try this see if it works. If not please give more details like the functions where you write the text in the UIlable
您已经创建了一个自定义类 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?