小编Vic*_*tor的帖子

Swift以编程方式导航到另一个视图控制器/场景

我正在使用以下代码以编程方式导航到另一个ViewController.它工作正常,但有些隐藏了navigation bar.我该如何解决?(导航栏被embeding创建ViewControllernavigation 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)

uinavigationbar viewcontroller ios swift

62
推荐指数
6
解决办法
14万
查看次数

Firebase获得儿童ID swift ios

我的Firebase看起来像这样.Bellow Active_Orderschilds根据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)

ios firebase swift firebase-realtime-database

9
推荐指数
1
解决办法
4430
查看次数

Swift MapKit自定义当前位置标记

这就是我project目前的样子.我的问题是,如何将蓝色球(当前位置)更改为自定义图像图标

location mapkit ios swift

7
推荐指数
1
解决办法
7654
查看次数

Swift 3.0-NSNumber和Int无法应用于操作数

var Rating = self.currentPerson.Rating

let c = Rating - 1
Run Code Online (Sandbox Code Playgroud)

我试着去获得value xself.currentPerson.Rating和减去1 value x。但是我只得到错误提示。

错误:二进制运算符“-”不能应用于类型为“ NSNumber”和“ Int”的操作数

问题:我该如何解决?

谢谢

nsnumber ios swift

4
推荐指数
1
解决办法
2845
查看次数

swift ios - 如何从AppDelegate在ViewController中运行函数

我试图在某些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)

我错过了什么?

谢谢!

function func ios appdelegate swift

4
推荐指数
1
解决办法
8100
查看次数

使用GMS进行Swift Map样式设计

我正在使用GMS(Google Maps SDK)在我当前的项目中,它看起来像这样

style地图可能是这样的吗?并仍然使用GMS.

styles ios gmsmapview swift

3
推荐指数
1
解决办法
1747
查看次数

播放结束后无法重播视频

我使用以下代码来揭示两个不同的视频源作为背景。“ 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)

error-handling ios swift

2
推荐指数
1
解决办法
1446
查看次数

停止NSTimer并关闭视图控制器(swift)

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?谢谢!

nstimer viewcontroller ios swift

1
推荐指数
1
解决办法
2413
查看次数