快速等待警报

时间:2015-07-06 04:59:48

标签: ios alert messages

Xcode 6,单视图控制器,swift

我正在制作一个像tic tac toe这样的游戏,我想知道如何设置一个弹出/警告说"等待玩家进行下一步行动"并且它下面有一个小旋转装载器,然后当玩家移动时,消息在等待的玩家消失,而另一个玩家等待消息弹出。感谢您关注并帮助。

1 个答案:

答案 0 :(得分:1)

尝试使用MBProgressHUD。它是一个最适合您需求的开源库。

提供您想要的信息。这将在纺车下面。

let loadingNotification = MBProgressHUD.showHUDAddedTo(self.view, animated: true)
loadingNotification.mode = MBProgressHUDMode.Indeterminate
loadingNotification.labelText = "Waiting for player to make next move"

//and to dismiss it : 
MBProgressHUD.hideAllHUDsForView(self.view, animated: true)

更新, 如何操作(桥接和全部):

步骤

  1. MBProgressHUD.h and .m拖放到您的项目中。
  2. 它会自动要求bridgingNO (因为我们会手动执行此操作)。
  3. 按名称Bridge.h
  4. 添加新文件(仅限标题文件.h)
  5. 在新创建的文件中键入#import "MBProgressHUD.h",即Bridge.h
  6. 转到项目目标并选择顶部项目(由项目名称显示)。
  7. 转到build settings并确保选中all
  8. 在搜索框(左上角)中输入swift compiler
  9. 更改Objective-C Bridging Header的值并将您的(Bridge.h)文件名放在那里。
  10. 现在在你的Swift文件中做东西:)