当我点击我的按钮时,我的函数被调用
[myBtn addTarget:self action:@selector(myFunction) forControlEvents:UIControlEventTouchUpInside];
在我的函数中,将执行一组复杂的语句并花费一点时间来运行,所以我想显示 Loading (UIActivityIndicatorView) 如下:
-(void) addTradeAction {
//Show Loading
[SharedAppDelegate showLoading];
//disable user interaction
self.view.userInteractionEnabled = NO;
//execute call webservice in here - may be take 10s
//Hide Loading
[ShareAppDelegate hideLoading];
}
当点击 myBtn(我的按钮)-> 3s 或 4s 后,[ShareAppDelegate showLoading] 被调用。
当我在其他函数上使用 [ShareAppDelegate showLoading] 时,这是不寻常的,-> 它工作得非常好,我的意思是所有语句都按顺序执行。
所有我想要的,当我点击我的按钮时,将立即调用加载。
提前谢谢