开发者

Cannot unhide UILabel or UIImageView

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!


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜