简体   繁体   English

单击下一个视图控制器的按钮时,如何显示加载标签?

[英]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.

相关问题 当我在集合视图中单击按钮时,我无法将值传递给下一个视图控制器 - when I click button in collection view, i I can't pass value to next view controller 如何从标签中显示文本? - How do I get my text from a label to show up? 如何在快速单击按钮时获取 tableview 标签值 - how can I get tableview label value on button click in swift 如何在子视图中获取按钮以在视图控制器中启用rightbarbuttonitem - How can I get a button in my subview to enable the rightbarbuttonitem in my view controller 推送视图控制器时标签不显示 - Label not showing up when I push view controller 如何从弹出窗口获取图像并将其显示在视图控制器中 - How can I get a image from popover and show it in the view controller 如何在按下按钮时使按钮弹出警报视图并返回主视图控制器? - How Do I Make A Button Get An Alert View To Pop Up When Pressed And Go Back To The Main View Controller? 当我选择UITableViewCell时,我的视图控制器标签就是后面的动作 - When I select a UITableViewCell, my view controller label is an action behind 为什么我再次隐藏并显示时,iOS工具栏视图会添加到加载视图的顶部? - Why does the iOS toolbar view get added on top of my loading view when I hide and show it again? 如何将文本字段的文本输入到视图控制器中? - How can I get the textfield's text into my view controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM