无法取消隐藏 UILabel 或 UIImageView

发布于 2024-09-17 07:25:16 字数 1031 浏览 4 评论 0原文

我刚刚开始 iPhone 开发,遇到了一个恼人的问题。我正在从一个视图转换到另一个视图,但是在此期间我想显示加载图像。

该控制器当前包含 TableView 和 TabControl。我已将图像和标签添加到控件(“正在加载”图像),并将它们链接到其关联的属性。然后它们在主控件中被@synthesized。

如果我在设计器中将这两个元素设置为“隐藏”,它们就不会显示。如果我不这样做,他们就会这样做——这是有道理的。

但是,如果我将它们都设置为隐藏,然后以编程方式调用 imageView.hidden=NO,它不会“出现”。我有什么遗漏的吗?如果初始属性设置为隐藏=否,我可以通过编程方式将其设置为是,但不能返回到否。设置这些控件的 .alpha 时也是如此。

请参阅下面我正在使用的代码。任何帮助将不胜感激 - 谢谢:)

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

 ForumThread *thread = [threadsArray objectAtIndex:indexPath.row];

 loadingLabel.hidden = NO;
 imageView.hidden = NO;

 ThreadViewController *threadViewController = [[ThreadViewController alloc] initWithThreadId: [thread threadID]];

 loadingLabel.hidden = YES;
 imageView.hidden = YES;

 [[self navigationController] pushViewController:threadViewController animated:YES];

 threadViewController.title = [thread threadTitle]; 
 [threadViewController release];   
}

应该有大约 2 秒的间隙,图像/标签应该可见。任何帮助将不胜感激!

I've just started iPhone development, and have come across an annoying problem. I am transitioning from one view to another, however in the interim I'd like to display a loading image.

The controller currently contains a TableView and TabControl. I have added an image and label to the control (of a 'loading' image) and linked them up to their associated properties. They are then @synthesized in the main control.

If I set both of these elements to 'hidden' in the designer, they don't show. If I don't, they do - which makes sense.

However, if I set them both to hidden, then programmatically call imageView.hidden=NO, it does not 'appear'. Is there something I'm missing? If the initial property is set to hidden=NO, i can programmtically set this to YES, but not back to NO. The same applies when setting the .alpha of these controls.

See below for the code i'm using. Any help would be appreciated - thanks :)

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

 ForumThread *thread = [threadsArray objectAtIndex:indexPath.row];

 loadingLabel.hidden = NO;
 imageView.hidden = NO;

 ThreadViewController *threadViewController = [[ThreadViewController alloc] initWithThreadId: [thread threadID]];

 loadingLabel.hidden = YES;
 imageView.hidden = YES;

 [[self navigationController] pushViewController:threadViewController animated:YES];

 threadViewController.title = [thread threadTitle]; 
 [threadViewController release];   
}

There should be a gap of about 2s where the image/label should be visible. Any help would be appreciated!

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

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

发布评论

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

评论(1

下壹個目標 2024-09-24 07:25:16

在您的情况下,标签和 imageView 将被隐藏。因为隐藏标签没有延迟。您可以使用计时器来延迟隐藏。试试这个。我还没有测试过。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

 ForumThread *thread = [threadsArray objectAtIndex:indexPath.row];

 loadingLabel.hidden = NO;
 imageView.hidden = NO;

 ThreadViewController *threadViewController = [[ThreadViewController alloc] initWithThreadId: [thread threadID]];

  NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(ShowLabel) userInfo:nil repeats:NO];


 [[self navigationController] pushViewController:threadViewController animated:YES];

 threadViewController.title = [thread threadTitle]; 
 [threadViewController release];   
}
-(void) ShowLabel
{
 loadingLabel.hidden = YES;
 imageView.hidden = YES;
}

In your case label and imageView will be hidden. Because there is no delay in hiding the label. You can use the timer to delay the hiding. Try this. I have not tested it.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

 ForumThread *thread = [threadsArray objectAtIndex:indexPath.row];

 loadingLabel.hidden = NO;
 imageView.hidden = NO;

 ThreadViewController *threadViewController = [[ThreadViewController alloc] initWithThreadId: [thread threadID]];

  NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(ShowLabel) userInfo:nil repeats:NO];


 [[self navigationController] pushViewController:threadViewController animated:YES];

 threadViewController.title = [thread threadTitle]; 
 [threadViewController release];   
}
-(void) ShowLabel
{
 loadingLabel.hidden = YES;
 imageView.hidden = YES;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文