2017-05-30 45 views
-2

我在我的项目中创建了一个类。并且该类连接到服务器,并通过调用UIViewController中的send()函数将消息发送到服务器。Swift Event捕捉并知道?

服务器正在接收并通过发回消息作出响应。我的StreamDelegate(连接)获取事件,我收到消息。现在的问题。通过在用户界面中按下一个按钮,发送消息后,我想表现出一个TextView或标签的响应。但是,我如何从Connection类获取消息给ViewController?以及如何处理用户界面。我希望用户等待,而不是做其他的事情(也许检查登录)。

回答

0

我认为你应该使用负载指示:

let alertController = UIAlertController(title: nil, message: "Loading \n\n", preferredStyle: .alert) 

let spinnerIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) 

spinnerIndicator.center = CGPoint(x: 135.0, y: 65.5) 
spinnerIndicator.color = UIColor.black 
spinnerIndicator.startAnimating() 

alertController.view.addSubview(spinnerIndicator) 
self.present(alertController, animated: false, completion: nil) 

,当你有你的消息发回,只需使用:

alertController.dismiss(animated: true, completion: nil); 

予以驳回。 过程中显示的时间负载指示,用户无法点击或做任何事情。