标签: ios8

NSValue到Swift中的CLLocationCoordinate2D

我正在使用Contentful.com我的iOS应用程序作为内容后端.geo-point在我的Swift项目中,我不能让他们回到我身边.

Contentful文档说他们的API回报是" NSData与" CLLocationCoordinate2D struct.

NSValue在我的项目中接近这个,但我无法让它正常工作.这是我的代码:

var locationCoord:CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: 0,longitude: 0)

var locationData:NSData = entry.fields["location"] as NSData

var locationValue:NSValue = NSValue(bytes: locationData.bytes, objCType: "CLLocationCoordinate2D")

locationCoord = locationValue.MKCoordinateValue
Run Code Online (Sandbox Code Playgroud)

然而,locationCoord.latitudelocationCoord.longitude return错误值(他们总是被一个0.0).

有人能告诉我这里我做错了什么,以及如何正常工作?谢谢.

nsvalue cllocationcoordinate2d swift ios8

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

无法在xcode 6.2中找到Apple Watch模板

我刚刚下载了xcode 6.2来处理apple watch sdk.但我找不到苹果手表的模板.

在此输入图像描述

xcode ios8 apple-watch

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

在ios中添加视图控制器作为子视图

嗨,我想添加一个view controller作为child view.然后删除此view controller表单父视图.我正在使用以下代码来实现此目的.

 self.loginView = [self.storyboard instantiateViewControllerWithIdentifier:@"LOGIN"];
 [self.view addSubview:self.loginView.view];
Run Code Online (Sandbox Code Playgroud)

这段代码工作正常iOS8但是在iOS7这段代码中它不起作用它显示了屏幕的一半.显示了半部分登录.

有什么可以解决这个问题?

objective-c ios ios7 ios8

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

找不到变量:device

我陷入了这个phonegap项目.在Android和iOS <= 7上,一切都很完美,但在iOS> = 8.0时失败.将出现一个弹出窗口,其中显示消息:"找不到变量:device"

在此输入图像描述

这是我得到的消息:

这是我的HTML:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="msapplication-tap-highlight" content="no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
        <script type="text/javascript" src="cordova.js" charset="utf-8"></script>
        <script type="text/javascript" src="js/PushNotification.js" charset="utf-8"></script>
    </head>
    <body onload="documentReady();">
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
        </div>
        <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我在标签底部加载的'index.js'.

var myPushNotification;

// result …
Run Code Online (Sandbox Code Playgroud)

phonegap-plugins cordova phonegap-build phonegap-pushplugin ios8

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

如何在iOS中解压缩异步方式zip文件?

如何异步解压缩文件?目前我解压缩如下:

[SSZipArchive unzipFileAtPath:strZipFile toDestination:strDestPath];
Run Code Online (Sandbox Code Playgroud)

但这阻止了我的主线程,并且UI没有响应超过10秒.zip文件超过50MB,我在didFinishLaunching的委托中开始下载(以避免长时间闪屏,因为并不总是需要在开头使用该文件.)

objective-c ios ios7 ios8

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

为什么在Swift中使用仅类协议?

任何人都可以在Swift中向我解释只有类的协议.我了解协议是什么以及我们使用它们的原因.我也理解,当我们在其中使用引用类型对象时,建议使用仅类协议,并且希望仅将协议构造限制为类.但是,我找不到支持该建议的任何好答案.为什么推荐?在这种情况下使用普通协议有什么缺点.

protocols swift ios8

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

UIPanGestureRecognizer没有名为touchesBegan的成员

我正在尝试将UIPanGestureRecognizer子类化,我想我可能会做一些愚蠢的事情.我试图覆盖UIPanGestureRecognizer从UIGestureRecognizer继承的方法时遇到错误.

我有这个代码

class VPGesture: UIPanGestureRecognizer {
    override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesBegan(touches, withEvent: event)
    }

    override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesMoved(touches, withEvent: event);
    }

    override func touchesEnded(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesEnded(touches, withEvent: event);
    }

    override func touchesCancelled(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesCancelled(touches, withEvent: event);
    }
}
Run Code Online (Sandbox Code Playgroud)

这产生了这些错误

在此输入图像描述

非常感谢您的帮助.

iphone cocoa-touch ios swift ios8

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

如何在Swift for iOS8中的UITextField中仅限制1个小数条目?

我已经四处寻找这个,但似乎仍无法让它发挥作用.我有一个简单的iOS程序,带有UITextField,可以将Farenheit转换为Celsius和Kelvin.我试图在这个UITextField中只限制1个小数.例如98.9是可以​​的但98..9不是.

这是我想要限制只有1位小数的函数.我想要的是如果输入1个小数,那么它将不允许输入另一个1,但是当然在第一个小数后仍然可以输入数字.

       func farenheitButton(sender: AnyObject)
      {
        var fVal = self.farenheitTextLabel.text
        var cVal = self.celsiusTextLabel.text
        var kVal = self.kelvinTextLabel.text

        if let fVal = self.farenheitTextLabel.text?.toDouble()
        {
          var fValx = self.farenheitTextLabel.text
          var fDoubleValue : Double = NSString (string: fValx).doubleValue

          var fToC = (fDoubleValue - 32) * (5/9) //convert Farenheit to Celsius formula
          var fToK = ((fDoubleValue - 32) / (1.8000)) + 273.15 //convert Farenheit to Kelvin formula

          //create string from value with a format
          var afToC : Double = fToC
          var bfToC : …
Run Code Online (Sandbox Code Playgroud)

ios swift ios8

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

主线程阻塞导致应用程序在iOS 8中崩溃

我的应用程序在启动时崩溃,因为"未能及时更新场景"

这是因为可达性不能按时返回这是堆栈跟踪

com.tjango.Plus3 failed to scene-update in time

Elapsed total CPU time (seconds): 2.590 (user 2.590, system 0.000), 12% CPU 
Elapsed application CPU time (seconds): 0.302, 1% CPU


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
_semaphore_wait_trap + 8
__dispatch_semaphore_wait_slow + 252
_xpc_connection_send_message_with_reply_sync + 184
___SCNetworkReachabilityServer_targetStatus + 192
___SCNetworkReachabilityGetFlags + 440
_SCNetworkReachabilityGetFlags + 232
-[Reachability currentReachabilityStatus] Reachability.m:295

这只发生在iOS 8上.

它被卡住的功能是Apple的Reachability库:我无法弄清楚为什么这个功能会阻止它.

- (NetworkStatus)currentReachabilityStatus

{

    NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef");

    NetworkStatus returnValue = NotReachable;

    SCNetworkReachabilityFlags flags;



    if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) …

iphone reachability ios ios8

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

核心数据:更新子上下文

如果我有一个NSManagedObjectContext和两个子节点,一个用于从Web服务(A)进行后台更新,另一个用于UI线程(B)中的操作,则问题是:如何通知NSManagedObjectContext B有关父管理对象的更改上下文一旦使用新信息更新后台上下文(A)并将其保存到父上下文中?

谢谢

core-data ios ios8

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