[英]How can I get my loading label to show up when I click button to next view controller?
I have attached the UIButton to a method for when it is pressed: 我已将UIButton附加到按下时的方法上:
- (IBAction)searchButtonPressed:(id)sender
{
NSLog(@"Search button pressed");
self.loadingLabel.hidden = false;
}
The problem is that when I click on the search button it is pausing for a few seconds (the button does that pressed down effect), however I want to put up a loading screen (as a UILabel) instead of this so the user knows what is happening. 问题是,当我单击搜索按钮时,它会暂停几秒钟(该按钮确实会产生按下效果),但是我想放一个加载屏幕(作为UILabel),而不是这样,以便用户知道正在发生。 My searchButtonPressed method does not work for making the loadingLabel visible.
我的searchButtonPressed方法不适用于使loadingLabel可见。 The UIButton opens another view controller when pressed which contains a NSScanner that is parsing through some text.
按下时,UIButton将打开另一个视图控制器,其中包含正在通过某些文本进行解析的NSScanner。 This is what is causing the delay (it takes a few seconds before the next view controller is actually visible).
这就是造成延迟的原因(下一个视图控制器实际可见之前需要花费几秒钟)。 How can I display a loading screen (as UILabel) when switching from one view controller to another while it is in process of taking care of the viewdidload in next view controller?
当一个视图控制器正在处理下一视图控制器中的viewdidload时,如何从一个视图控制器切换到另一个视图时显示加载屏幕(如UILabel)? I think that the view controller does not actually show until the viewdidload of that view controller is completed.
我认为在完成该视图控制器的viewdidload之前,该视图控制器实际上不会显示。 Thank you.
谢谢。
move your NSScanner to backgound in viedDidload or bring it to - (void)viewDidAppear:(BOOL)animated
(in backgound). 将您的NSScanner移至viedDidload中的backgound或将其置于
- (void)viewDidAppear:(BOOL)animated
(backgound中)。
Show a loading view in navigationController view when press button in previous view, set tag for this loading view 在上一个视图中按按钮时,在navigationController视图中显示一个加载视图,为此加载视图设置标签
When task is completed go to main thread to reload view and hide this loading view (can get it by tag) 任务完成后,转到主线程以重新加载视图并隐藏此加载视图(可以通过标签获取)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.