在iOS模拟器问题中运行Apple Watch

我试图在iOS模拟器中运行Apple WatchKit目录示例代码 。 但我一直禁用Apple Watch模拟器。 我必须做什么?

如何在Swift中使用htonl设置整数字节顺序?

我试图在Swift中使用htonl()设置整数字节顺序,但是编译器没有findhtonl()方法。 我一直在使用这个作为我的参考: 追加NSInteger到NSMutableData 这是我的代码: import Foundation import CFNetwork import CoreFoundation var data = NSMutableData() var number : UInt32 = 12 var convertedNumber : UInt32 = htonl(number) data.appendBytes(&convertedNumber, length: 4) 我刚刚在一个操场上运行。 错误是: Use of unresolved identifier 'htonl'

在调用completeTransition之后,导航栏被调整:在自定义转换中

我的目标是在启动应用程序时从类似于跳板图标的视图中为用户提供缩放模式转换。 所呈现的视图控制器正确放大,但导航栏在状态栏下的位置错误。 调用[transitionContext completeTransition:finished]后,该位置得到纠正。 如何从转换开始就使它正确无误? 这是一个屏幕logging的错误:http: //youtu.be/7LKU4lzb-uw (故障是在第六秒的logging) UIViewControllerAnimatedTransitioning代码: – (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; CGPoint viewCenter = self.view.center; CGSize viewSize = self.view.frame.size; CGSize controllerSize = toViewController.view.frame.size; CGFloat controllerFromX = viewCenter.x – (controllerSize.width / 2); CGFloat controllerFromY = viewCenter.y – (controllerSize.height / 2); […]

如何在Xcode 6上testing应用程序扩展

有谁知道如何执行应用程序扩展目标的unit testing,特别是键盘扩展目标? 我试过了什么(在unit testing目标中): 在“常规”水龙头中,将其目标设置为扩展目标而不是容器应用程序。 将“Bu​​ndle Loader”设置为扩展目标二进制文件的path,该文件看起来像$(BUILT_PRODUCTS_DIR)/com.mycompany.keyboard.appex/com.mycompany.keyboard 将“testing主机”设置为$(BUNDLE_LOADER) 。 在“构build阶段”点击,将“目标依赖项”设置为容器应用程序和扩展。 完成这些事情之后,我可以成功构build它,但是总会得到“testing失败”(Test Failed Test target SogouInputTests encountered an error (Test session exited(1). without checking in. If you believe this error represents a bug, please attach the log file at /tmp/TestStatus-UXfvxw.log) 。 我正在使用Xcode 6 beta 3。

什么时候应该使用__bridge与CFBridgingRelease / CFBridgingRetain?

我有这个代码使用“__bridge”来投射颜色的ID: CGColorRef tabColor = (5 == 5 ? [UIColor blueColor].CGColor : [UIColor greenColor].CGColor); CGColorRef startColor = [UIColor whiteColor].CGColor; CGColorRef endColor = tabColor; NSArray *colors = [NSArray arrayWithObjects:(__bridge id)startColor, (__bridge id)endColor, nil]; CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)colors, locations); 但会: NSArray *colors = [NSArray arrayWithObjects:(id)CFBridgingRelease(startColor), (id)CFBridgingRelease(endColor), nil]; CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)CFBridgingRetain(colors), locations); 成为更好的解决scheme?

iOS 9 supportedInterfaceOrientations不起作用

我有一个UIViewController与下面的代码: – (BOOL) shouldAutorotate { return NO; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationPortrait; } 我没有使用UINavigationController 。 当这个UIViewController被显示时,设备仍然会旋转到横向。 我针对iOS 9,这里有什么问题?

用SwiftyJSON处理JSON的例子

我想用SwiftJSON来处理json,但是我堆积了。 有没有人给我示例代码? 我试图使用这个库。 https://github.com/SwiftyJSON/SwiftyJSON 虽然我在同一个项目中放置了SwiftyJSON.swift,但是我有错误“没有这样的模块”SwiftyJSON“”所以纠正我的代码或者显示示例代码处理json从web与swiftyJSON库。 这是我的代码: import UIKit import SwiftyJSON // No such module "SwiftyJSON" class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let url = NSURL(string: "http://express.heartrails.com/api/json?method=getPrefectures") var request = NSURLRequest(URL: url!) var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: nil, error: nil) […]

苹果手表模拟器问题

我正在尝试debugging并在苹果手表模拟器上运行应用程序。 我曾尝试通过使用不同的目标通知,Glance和Watch应用程序,但苹果模拟器不显示任何东西..它卡在等待附加过程的扩展。 我只是看到苹果手表模拟器的黑屏。 我做错了什么? 如何克服这个问题?

插件com.apple.share.Facebook.post无效

在我的应用程序中,我使用下面的代码,允许与文本共享图像: – (IBAction)sharePressed:(id)sender { UIImage *postingImage = [UIImage imageWithContentsOfFile:self.filepath]; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Lorem ipsum", postingImage] applicationActivities:nil; [self presentViewController:activityViewController animated:YES completion:nil]; } 将图像发布到Facebook工作正常,它出现在我的FB墙上,但是在我的控制台中,我收到以下消息: plugin com.apple.share.Facebook.post invalidated 我已经在几台设备上进行了testing,据我所见,只发生在安装了iOS 8.1的iPhone 6上。 任何人都知道这个信息是什么意思,以及如何防止它显示?

在原始iOS应用和应用扩展之间共享代码

在iOS应用和扩展程序之间共享课程 我想在我的应用程序和扩展应用程序中使用自定义类。 如果我只是在主要的应用程序文件夹中的类,扩展不会拿起它。 我试着把它复制到扩展文件夹中,但我当然得到了invalid redeclaration of [my class]错误的invalid redeclaration of [my class] 。 什么是最好的解决scheme? 这只是一个类,不是多个资源。