我正在使用以下代码以编程方式导航到另一个ViewController.它工作正常,但有些隐藏了navigation bar.我该如何解决?(导航栏被embeding创建ViewController的navigation controller,如果该事项).
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("nextView") as NextViewController
self.presentViewController(nextViewController, animated:true, completion:nil)
Run Code Online (Sandbox Code Playgroud) 我的Firebase看起来像这样.Bellow Active_Orders它childs根据UID(用户ID)显示不同的名称.
这是我的代码,无论名称是什么,都可以获得孩子的身份证.但它似乎根本不起作用.什么是正确的方式来获得child ID?谢谢
databaseRef.child("Active_Orders").observeEventType(FIRDataEventType.Value, withBlock: {
snapshot in
//Get customerUID
let customerUID = snapshot.value!.objectForKey("username") as! String
self.setText("customerUID", value: customerUID)
Run Code Online (Sandbox Code Playgroud) var Rating = self.currentPerson.Rating
let c = Rating - 1
Run Code Online (Sandbox Code Playgroud)
我试着去获得value x的self.currentPerson.Rating和减去1 value x。但是我只得到错误提示。
错误:二进制运算符“-”不能应用于类型为“ NSNumber”和“ Int”的操作数
问题:我该如何解决?
谢谢
我试图在某些ViewController使用中运行一个函数AppDelegate
func applicationDidBecomeActive(_ application: UIApplication) {
ViewController().grabData()
}
Run Code Online (Sandbox Code Playgroud)
但不知何故,当应用程序从后台进入应用程序后变为活动状态时,该功能似乎根本无法运行.
该功能看起来像这样
func grabData() {
self._DATASERVICE_GET_STATS(completion: { (int) -> () in
if int == 0 {
print("Nothing")
} else {
print(int)
for (_, data) in self.userDataArray.enumerated() {
let number = Double(data["wage"]!)
let x = number!/3600
let z = Double(x * Double(int))
self.money += z
let y = Double(round(1000*self.money)/1000)
self.checkInButtonLabel.text = "\(y) KR"
}
self.startCounting()
self.workingStatus = 1
}
})
}
Run Code Online (Sandbox Code Playgroud)
并使用此var
var money: Double = 0.000
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
谢谢!
我使用以下代码来揭示两个不同的视频源作为背景。“ selectVideo”(SegmentedControl)用于选择视频。问题在下面。
@IBAction func selectVideo(sender: AnyObject) {
if self.Controller.selectedIndex == 1 {
self.videoBackgroundCustomer()
}
if self.Controller.selectedIndex == 0 {
self.videoBackgroundDriver()
}
}
func videoBackgroundDriver() {
//Load video background.
let videoURL: NSURL = NSBundle.mainBundle().URLForResource("background_video_2", withExtension: "mp4")!
player = AVPlayer(URL: videoURL)
videoBackground()
}
//Video background customer
func videoBackgroundCustomer() {
//Load video background.
let videoURL: NSURL = NSBundle.mainBundle().URLForResource("background_video_1", withExtension: "mp4")!
player = AVPlayer(URL: videoURL)
videoBackground()
}
//Vieobackground-code part 2, provides with less code.
func videoBackground() {
player?.actionAtItemEnd = .None
player?.muted = …Run Code Online (Sandbox Code Playgroud) 我NSTimer用来在我的firebase数据库中查找更新.我把代码放在我的内部viewDidLoad().
NSTimer.scheduledTimerWithTimeInterval(5.0, target: self, selector: #selector(DriversInterfaceViewController.CheckFormularChild), userInfo: nil, repeats: true)
Run Code Online (Sandbox Code Playgroud)
当用户在数据库中收到文件时,我希望用户转到另一个文件ViewController.问题是旧的ViewController是在后台运行还是计时器在更改时不会停止View Controller.
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("recievedMission") as! RecievedMissionViewController
self.navigationController!.pushViewController(nextViewController, animated: true)
Run Code Online (Sandbox Code Playgroud)
我如何解雇旧的View Controller或如何停止NSTimer programmatically?谢谢!