[成长记录]毕业设计的那段日子2

两天时间,跌跌撞撞,小问题不断,不过最终可以在真机子上调试了


遇到几个小坎,总结一下

1,按钮点了没反应,

原因

  @IBActionfunc checkTapped(sender: UIButton)

这句话不能手打,必须从storyboard里面按control键拉过来才能用,拉过来以后注意下拉菜单connection 那里记得改成action


2.点按钮之后没有经纬度,label标签变白色,原因为从系统请求位置请求服务,

解决办法,在info.plist中加一行

NSLocationWhenInUseUsageDescription  ,别少单词,,,我因为少了一个use,找了半天错才发现,,,,


3.经纬度总是定位美国apple总部,,,后来问了别人才知道,iOS 模拟器是不带定位服务的,也不能用mac电脑的定位代替ios模拟器的位置,只能真机测试,,,,,


4.。更新一下到10.11.。。又跟俩小时xcode...趁这段时间玩热血英豪了趁合区之前好好爽了一下,题外话- 。-

跟新完了借同学手机测试又遇到问题,,,,说是不能测试,,,后来问了同学‘这篇文章帮助很大,附链接


https://www.skyfox.org/ios-xcode7-debug-device.html


这个弄好到手机上又说不信任我开发的软件哦呵呵呵呵呵


点设置--通用---描述文件,点信任即可。。。。。。



最后是现阶段代码只有 viewcontroller里的代码,

前端没东西- -,




import UIKit

import CoreLocation //we need to use the coreLocation framework



//we need to make the viewcontroller conform the CLLocation delegate

//so we change class ViewController:UIViewController to

//class ViewController:UIViewController,CLLocationManagerDelegate

class ViewController: UIViewController,CLLocationManagerDelegate {

    @IBOutlet weak var check: UIButton!

    @IBOutlet weak var resultBoard: UILabel!

    @IBOutlet weak var resultBoard1: UILabel!

    

    

    var latitude:String = ""

    var longitude:String = ""

    

    //then create an location manager property

    let locationManager = CLLocationManager()

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

        

        self.locationManager.delegate = self //assign a delegate to the object

        self.locationManager.desiredAccuracy = kCLLocationAccuracyBest //set accuracy

        self.locationManager.requestWhenInUseAuthorization()//we need the current location when the app is open so need to use this InUseAuthorization

        //the code above is for setting up the locationManager.and next line of code is let the locationmanager start to work

        self.locationManager.startUpdatingLocation()//Let the locationManager start working

    }


    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

    //the next thing we need is the delegate method 

    //this part is let the system start to update and receive location data from the

    //location service

    func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

       

       // self.check.setTitle("test", forState: UIControlState.Normal)

              if( CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse){

                

                self.longitude = "\(manager.location!.coordinate.latitude)"

                

                self.latitude = "\(manager.location!.coordinate.longitude)"

                

        }

        else

        {

            self.check.setTitle("定位服务未开启", forState: UIControlState.Normal)

        }

        

    }

    

    

    @IBAction func checkTapped(sender: UIButton) {

       

        self.locationManager.stopUpdatingLocation()


        let a:String = self.latitude

        let b:String = self.longitude

        

        print(a)

        print(b)

            self.resultBoard.text =  a

            self.resultBoard1.text = b

        

    }

    

    

    

目前代码功能,追踪定位,一个用户的经纬度,啊总之这个是我开发之前最头疼的问题,,现在解决了,,


不过又有新问题出现,,,

1.就是上课签到这个每节课上课地点不同,那么签到标准经纬度怎么定,老师来设置么?

那岂不是又牵扯到网络通讯方面的代码了- -。。。。。。。。。。。。。。。

很难的样子- -。。。。。。。

2.每节课上课地方不一样,上课应在的经纬度是不是还要搞个session啥的,,过期了就要改,,,我也不是很懂啊,以前听java课睡意朦胧之时好像听到有这么一说- -。。。。。。。。。。

3。上面两个终极难题最后解决,实在不行找导师去,,,

明后天主要先把成员管理这块弄掉,

登录注册啥的

还有软件里面点个按钮跳转到另外一页是怎么弄弄,这个也是要解决的问题,,,以前搞网页简单,一个url直接跳过去,这个app上怎么弄弄要查一下,


4,最后有个考勤成绩管理,这个对本学渣来说也是有难度的,,,签到一次 签到次数++?,最后输出本学期签到成功总次数???

然后和应到次数比一下?算百分比????这个应到次数谁来设置?每种课每学期上课次数不一样啊,,,饿好多蛋疼问题,,,慢慢解决还有时间希望自己能持续这个劲头。。。。。。。。。。。。。。。。。。。。。。。。。。。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值