我有这个代码设置一些标签,隐藏和其他几个,然后删除我从屏幕上制作的自定义加载视图,这是代码:
self.yourPlanLabel.text = [infoArray objectAtIndex:0];
self.yourMealLabel.text = [infoArray objectAtIndex:1];
self.yourBalanceLabel.text = [infoArray objectAtIndex:2];
self.usernameField.hidden = YES;
self.passwordField.hidden = YES;
self.loginBtn.hidden = YES;
self.yourPlanLabel.hidden = NO;
self.yourMealLabel.hidden = NO;
self.yourBalanceLabel.hidden = NO;
//remove loading view
[self.loadingView removeFromSuperview];
但加载视图首先消失,然后几秒后标签出现/消失,这取决于我设置的内容,为什么加载视图首先消失,当它位于代码的底部时?
感谢您的帮助:)
以下是我如何调用加载视图:
self.loadingView = [[LoadingView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:self.loadingView];
[self.navigationController.view addSubview:self.loadingView];
[self.loadingView setCenter:CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2 +32)];
这是加载视图的.m
https://gist.github.com/anonymous/e0a34fb49375dfeaca39
我现在正在做这个
dispatch_async(dispatch_get_main_queue(), ^{
self.yourPlanLabel.text = [infoArray objectAtIndex:0];
self.yourMealLabel.text = [infoArray objectAtIndex:1];
self.yourBalanceLabel.text = [infoArray objectAtIndex:2];
self.usernameField.hidden = YES;
self.passwordField.hidden = YES;
self.loginBtn.hidden = YES;
self.mealLabel.hidden = NO;
self.planLabel.hidden = NO;
self.balanceLabel.hidden = NO;
self.yourPlanLabel.hidden = NO;
self.yourMealLabel.hidden = NO;
self.yourBalanceLabel.hidden = NO;
self.loadingView.hidden = YES;
[self.loadingView removeFromSuperview];
});
仍然无法正常工作?
答案 0 :(得分:0)
如果您在viewDidLoad中执行上述所有设置,请尝试移动隐藏功能 viewDidAppear。
所以
-(void)viewDidAppear
{
[self.loadingView removeFromSuperview];
}