我试图检测 AppleWatch 上所有四个方向的滑动。但是我不清楚如何为我插入故事板的 WKSwipeGestureRecognizer 的方向分配许多值。我试过:
swiper.direction = [.right , .left , .up , .down]
Run Code Online (Sandbox Code Playgroud)
编译器有趣地接受了这一点,与使用按位 | 不同,但是,使用此配置,功能:
@IBAction func swipe(_ sender: Any) {
switch swiper.direction {
case WKSwipeGestureRecognizerDirection.right:
print("Swiped right")
case WKSwipeGestureRecognizerDirection.down:
print("Swiped down")
case WKSwipeGestureRecognizerDirection.left:
print("Swiped left")
case WKSwipeGestureRecognizerDirection.up:
print("Swiped up")
default:
break
}
}
Run Code Online (Sandbox Code Playgroud)
很少被调用,当它是 swiper.direction 时,总是 .right。
Apple 非常神秘:https : //developer.apple.com/reference/watchkit/wkswipegesturerecognizer/1650828-direction 说:
“此属性的默认值是正确的。您可以指定多个方向以使用相同的手势识别器跟踪多个方向的滑动。”
不透露如何。
我一直收到一个测试用户对带有标题的Swift项目的崩溃日志:
例外类型:SIGTRAP
这是crashlog的相关部分:
Hardware Model: iPad4,2
Process: Jam Session [204]
Path: /var/mobile/Containers/Bundle/Application/FADFF299-ABDC-46AA-8B77-BF4F77301DBF/Jam Session.app/Jam Session
Identifier: it.info.music.jamsession
Version: 1.0 (1.0.8)
Code Type: ARM-64
Parent Process: ??? [1]
Date/Time: 2016-02-26 11:06:46 +0000
OS Version: iPhone OS 9.2.1 (13D15)
Report Version: 104
Exception Type: SIGTRAP
Exception Codes: #0 at 0x10002971c
Crashed Thread: 0
Thread 0 Crashed:
0 Jam Session 0x000000010002971c 0x10000c000 + 120604
1 Jam Session 0x0000000100023ee4 0x10000c000 + 98020
2 UIKit 0x0000000187af931c 0x187794000 + 3560220
3 UIKit 0x0000000187af9484 0x187794000 + 3560580
4 …Run Code Online (Sandbox Code Playgroud) 我正在将应用程序移植到iOS 6,我找到了一个解决方案,我已经设法触发断开视图控制器中的主视图控制器的显示,不再适用于iOS 6.
这是我用来触发iOS6上的操作的代码片段,如果设备被旋转:
- (void)hideMaster:(BOOL)hide {
[self clearOverlay];
UISplitViewController* spv = appDelegate.splitViewController;
NSLog(@"hidemaster: I do %@show the master", (hide?@"not ":@""));
self.hiddenMaster= hide;
NSLog(@"delegate=%@", spv.delegate);
[spv.view setNeedsLayout];
spv.delegate=nil;
spv.delegate=self;
}
- (BOOL)splitViewController:(UISplitViewController*)svc shouldHideViewController: (UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {
NSLog(@"Spv: I do %@show the master", (self.hiddenMaster?@"not ":@""));
return self.hiddenMaster;
}
Run Code Online (Sandbox Code Playgroud)
如何在用户旋转设备时强制触发shouldHideViewController回调?
谢谢,Fabrizio Bartolomucci
我在我的iOS应用程序中直接链接PLCrashReporter而不使用任何外部工具,现在当我尝试在Xcode 7上编译它时,我收到链接错误:
ld:'.../CrashReporter.framework/CrashReporter(libCrashReporter-iphoneos.a-armv7-master.o)'不包含bitcode.您必须在启用bitcode(Xcode设置ENABLE_BITCODE)的情况下重建它,从供应商处获取更新的库,或禁用此目标的bitcode.对于架构armv7
我在哪里获得更新的框架或源代码来启用bitcode编译它们并摆脱错误而不禁用整个项目的bitcode?
我将一个文件从Objective_c移植到Swift,它的配置改变了tabbar颜色:我在objective-c中使用的代码是:
UIColor* barColor=[UIColor colorWithRed:.88 green:.05 blue:.05 alpha:1];
if([self.navigationController.navigationBar respondsToSelector:@selector(barTintColor)])
{
// iOS7
self.navigationController.navigationBar.barTintColor = barColor;
}
else
{
[[UINavigationBar appearance] setTintColor:barColor];
// older
//self.navigationController.navigationBar.tintColor = barColor;
}
[super viewWillAppear:animated];
Run Code Online (Sandbox Code Playgroud)
和Swift中的相应代码是:
let barColor = UIColor(red:0.88, green:0.05, blue:0.05, alpha:1)
if UIDevice.currentDevice().systemVersion.compare("8.0", options: .NumericSearch) == .OrderedDescending
{
// iOS8+
UINavigationBar.appearance().tintColor=barColor
//UINavigationBar.appearance().translucent=false
}
else
{
self.navigationController!.navigationBar.barTintColor = barColor;
}
Run Code Online (Sandbox Code Playgroud)
然而,虽然objective-c代码确实改变了标签栏颜色,但相应的快速代码却没有受到损害,至少在模拟器上是这样.我做错了什么?
我发现我的 crontab 脚本无法按预期工作,因为它们无法写入 /var/log。我尝试执行命令:
sudo /usr/bin/php /var/www/html/iPhone/inarrivo/php/rome/process.php >> /var/log/romeLoading.log 2>&1
手工得到:
-bash: /var/log/romeLoading.log: 权限被拒绝
/var/log 权限为:
drwxr-xr-x。13 根根 4096 15 前 16.20 。
如果我反过来执行:
sudo touch /var/log/loadRome.log
我没有收到任何错误。
可能是什么问题?
请注意 Apache 没有受到威胁:我从根 crontab 和使用 sudo 从 shell 调用这些脚本作为测试。
我正在采用 WatchConnectivity,但我仍然支持没有此库的 iOS7 和 iOS 8。此外,我采用的协议 WCSessionDelegate 也不支持,但这个较旧的系统。在 ObjectiveC 中,我会使用预处理指令来屏蔽不支持它们的版本的声明和协议采用。我如何在 Swift 中处理这个问题,以便应用程序不会在旧系统上崩溃?
我有这个我在代码中无处不在的香草代码:
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration:configuration)
let listTask = session.dataTask(with: theRequest, completionHandler: {[weak self](data, response, error) in
})
Run Code Online (Sandbox Code Playgroud)
然而在一个特定的类中,编译器抱怨:
无法使用类型'的参数列表调用'dataTask'(with:URLRequest,completionHandler:(Data?,URLResponse?,Error?) - >())'
期望一个类型'的参数列表'(with:URLRequest,completionHandler:>(Data?,URLResponse?,Error?) - > Void)'
它如何将闭包的返回值推断为()而不是预期的Void?我反复复制其他类的代码,以免写错了.
我试图通过使用代码请求对healthkit中的类别进行授权:
let healthKitStore: HKHealthStore = HKHealthStore()
let healthKitTypesToWrite = Set(arrayLiteral:[
HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifierMindfulSession)
])
healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead) { (success, error) -> Void in
if( completion != nil )
{
completion(success:success,error:error)
}
}
Run Code Online (Sandbox Code Playgroud)
来自https://www.raywenderlich.com/86336/ios-8-healthkit-swift-getting-started.
然而,当我这样做时,我得到:
参数类型'[HKCategoryType?]'不符合预期类型'Hashable'
如何在Healthkit中保存类别,并且通常是一个专门用于HKCategoryType的教程,也可能是HKCategoryTypeIdentifierMindfulSession?
我有这个简单的字符串变量:
$query="SELECT * FROM striscie AS previous, striscie AS current WHERE previous.linea=current.linea AND current.ident=$striscia AND previous.position<current.position AND previous.position>current.position-$stops";
Run Code Online (Sandbox Code Playgroud)
然而,当我回应或使用它时,它转向:
SELECT * FROM striscie AS previous, striscie AS current
WHERE previous.linea=current.linea AND current.ident=897524 AND previous.positioncurrent.position-3
SELECT * FROM striscie AS previous, striscie AS current
WHERE previous.linea=current.linea AND current.ident=920173 AND previous.positioncurrent.position-2
Run Code Online (Sandbox Code Playgroud)
删除字符串的整个部分.我尝试重启Apache无济于事.可能是什么?
我发现“健康”应用程序具有“正念”部分,但我在文档中没有找到如何为该部分做出贡献。通过网络搜索满足这一要求,我得到了世界范围内撤退中心的集合……您能指导我一些有意义的事情吗?