Swift 3:用float增量replacec样式for循环

我在我的应用程序中有这样一个循环: for var hue = minHue; hue <= maxHue; hue += hueIncrement { let randomizedHue = UIColor.clipHue( Random.uniform(ClosedInterval(hue – dispersion, hue + dispersion)) ) colors.append(colorWithHue(randomizedHue)) } hueIncrement是浮动的 ,所以我不能使用范围运算符像这样: ..< 。 在Swift 3中实现这种循环的最好和最简单的方法是什么?

使用API​​时,Firebase API不会发送推送通知

我正在从Parse迁移到Firebase,并面临我们的ios应用程序出现问题。 Firebase API不会将推送通知发送到ios应用程序。 这就是即时通讯发送到https://fcm.googleapis.com/fcm/send { "to: "<registration token>", "priority": "high", "data": { "customId": "<my custom id>", "badge": 1, "sound": "cheering.caf", "alert": "New data is available" } } 而服务器正在成功返回 { "multicast_id":6917019914327105115, "success":1, "failure":0, "canonical_ids":0, "results":[{"message_id":"0:1468961966677585%f0f84693f9fd7ecd"}] } 但推动并没有实现。 如果我使用Firebase信息中心发送推送,即使直接使用令牌,推送也会发送。 我看到另一个开发人员在另一个Stackoverflow问题中抱怨无法使用服务器API发送推送通知 我尝试了join“优先级”的解决scheme:“高” ,但没有解决问题。 但它给了我一个线索:他们也在使用dev / sandbox推送证书。 我的怀疑是仪表板可以使用ios开发证书,但API不能。 这个问题只发生在iOS设备上,因为android应用程序正在通过API推送。 任何人都可以使用API​​和开发证书发送推送?

如何在多点触控序列中有效处理UITouches

我正在使用多点触控书写,所以基本上我正在做的是,我正在写手与支持,因为通常,它的用户如何写,我跟着这个链接如何忽略多点触控顺序中的某些UITouch点 一切都工作正常单触,但他们是一些问题,当我用手触摸屏幕,即多个UItouches写下面是我的代码 触摸开始,我经历了所有的触摸,我发现触摸与最高的位置,下面是我的代码 以下是我的代码 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* topmostTouch = self.trackingTouch; for (UITouch *touch in touches) { ctr = 0; touchStartPoint1 = [touch locationInView:self]; if(!topmostTouch || [topmostTouch locationInView:self].y > touchStartPoint1.y) { topmostTouch = touch; pts[0] = touchStartPoint1; } } self.trackingTouch = topmostTouch; } 在感动的时候,我只会采取self.trackingTouch,这是我触摸到的 我的触动移动下面的代码 -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if(self.trackingTouch== nil) { […]

NSDate没有返回正确的date

我打印这样的NSDate: NSDate *date = [NSDate date]; NSString *stringDate = [data description]; 现在是2011年7月1日11:43。 我的iPod甚至在顶栏上说。 但stringDate打印出来:2011-07-02 03:43:46 +0000 这显然是错误的。 我已经使用了NSDate数百万次,但从来没有这个问题。 什么可能是错的? 谢谢

在Objective-C代码中解密来自河豚的值

我收到服务器的encryption数据(BLOWFISH ALGORITHM),我必须在IOS中使用blowfishalgorithm来解密它。 你可以从这里下载我的代码: https ://www.dropbox.com/s/nswsm7des7isgd5/BlowfishTest-4.zip 我从这个任务挣扎了2天,我尝试了很多链接,发现一些有用的: Blowfish源代码 如何在iOS中实现Blowfishalgorithm http://www.codeding.com/articles/blowfish-encryption-algorithm-for-iphone 在第三个环节,我得到了ECB(我必须使用ECB进行解密)。 但是这个代码在解密之后也没有给出正确的输出。 我正在使用在线工具进行testing,并显示正确的输出: http : //www.tools4noobs.com/online_tools/decrypt/ Key = 20zE1E47BE57$51 Input value is = aed5c110d793f850521a4dd3a56a70d9 Algorithm = BLOWFISH Mode = ECB Decode the input using= Hexa output = aYzY1380188405 ( this is correct output which i want) 我得到:¹àÀhÒ¢º¹ÂÂF 这是我的代码: //Mode selected by default in nib: “ECB” NSString […]

无法强制UIViewController方向

我有一个景观ViewController的肖像应用程序。 我一直在挖掘很多关于如何强制方向横向时,应用程序被locking到肖像,我尝试了很多这里提出的解决scheme,不仅如此,但没有任何运气。 到目前为止,我设法自动旋转风景中需要的VC,但由于方向未locking,所有其他VC也将旋转。 override func viewDidAppear(animated: Bool) { let value = UIInterfaceOrientation.LandscapeRight.rawValue UIDevice.currentDevice().setValue(value, forKey: "orientation") } override func shouldAutorotate() -> Bool { return true } 经过更多的挖掘后,我find了一个示例项目,但当它在该项目中工作后,这似乎并没有为我工作。 这是在AppDelegate func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask { if self.window?.rootViewController?.presentedViewController is ConclusionReferencesVC { let conclusionReferencesVC = self.window!.rootViewController!.presentedViewController as! ConclusionReferencesVC if conclusionReferencesVC.isPresented { return UIInterfaceOrientationMask.LandscapeRight; } else { […]

iOS应用兼容性问题

我正在用Swift 2.1,Xcode 7.1.1做一个应用程序。 我希望它至less与iPhone 4S和5C兼容。 我configuration了我的项目设置与armv7架构,info.plist,但是当我发布我的版本,我只有在iTunes连接定义的arm64。 我需要在哪里正确configuration?

CABasicAnimation旋转返回到原来的位置

我旋转CALayer使用CABasicAnimation,并正常工作。 问题是,当我尝试旋转同一图层时,它将在旋转之前返回到其原始位置。 我预期的结果是,下一轮,它应该从结束的地方开始。 这是我的代码: CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; animation.fromValue = 0; animation.toValue = [NSNumber numberWithFloat:3.0]; animation.duration = 3.0; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; animation.autoreverses = NO; [calayer addAnimation:animation forKey:@"rotate"]; 我的代码有什么缺失? 谢谢

如何改变UIPickerView Selector的颜色

我有一个UIPicker,我想改变select器的颜色。 是否可以改变select器的颜色?

在iOS中从pdf文档中读取文本和图像

我在我的iPad应用程序中显示本地存储的PDF。 代码如下: NSString *path = [[NSBundle mainBundle] pathForResource:@"About Downloads" ofType:@"pdf"]; NSURL *targetURL = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; [pdfWebView loadRequest:request]; 现在,默认情况下,您不能从UIWebView呈现的PDF复制文本或图像。 有没有办法让用户从pdf中复制文本和/或图片? 我不熟悉CATitledLayer,所以我只是想知道在这种情况下是否可以提供帮助?