Tag: 迅速

在Swift中旋转UIImage

我用Swift使用Xcode 6.0.1。 我有一个UIImage,我想使用旧的图像作为源,新的图像旋转以某种方式另一个图像…说垂直翻转。 这个问题已经在几个月前解决了 。 但是,即使情况相同,该解决scheme也不适用于我。 当我有 var image = UIImage(CGImage: otherImage.CGImage, scale: 1.0, orientation: .DownMirrored) Xcode抱怨说在调用中有一个“额外的参数”尺度。 在检查Apple文档之后,这是没有意义的,因为该版本的初始化程序确实需要这三个参数。 抛开规模和方向的争论确实解决了这个问题,但阻止了我进行轮换。 我能find的唯一另外一个引用是这个人 ,他有同样的问题。 你怎么看? 我确实需要在这个版本的Xcode上运行,所以如果有一个替代的方法来执行旋转(我还没有find),这将是有用的。

每天在特定时间快速重复本地通知

我是iOS开发新手,但已经创build了应用程序,我正在尝试创build一个设置时间的每日通知。 目前通知对于给定的date/时间执行一次。 我不确定如何使用repeatInterval方法每天安排。 每天重复通知的最佳方法是什么? 任何帮助将不胜感激(Y)。 var dateComp:NSDateComponents = NSDateComponents() dateComp.year = 2015; dateComp.month = 06; dateComp.day = 03; dateComp.hour = 12; dateComp.minute = 55; dateComp.timeZone = NSTimeZone.systemTimeZone() var calender:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! var date:NSDate = calender.dateFromComponents(dateComp)! var notification:UILocalNotification = UILocalNotification() notification.category = "Daily Quote" notification.alertBody = quoteBook.randomQuote() notification.fireDate = date notification.repeatInterval = UIApplication.sharedApplication().scheduleLocalNotification(notification)

如何设置自适应多行UILabel文本?

我的故事板笔尖中有一个名为titleLabel的UILabel设置为其默认高度。 我希望它在编程上扩展高度以适应其内容。 这是我迄今为止所尝试的: // just setting content titleLabel.text = "You don't always know what you are getting with mass-market cloud computing services. But with SimpliCompute, the picture is clear. SimpliCompute gives you powerful virtual servers you can deploy using just your web browser. That's enterprise grade technology you can deploy and control on-the-fly." titleLabel.numberOfLines = […]

DestinationViewController Segue和UINavigationController swift

所以我有一个像这样的prepareForSegue方法: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "fromEventTableToAddEvent" { let addEventViewController: AddEventViewController = segue.destinationViewController as! AddEventViewController addEventViewController.newTagArray = newTagArray } } 但是,在运行时,应用程序崩溃并且logging了这条消息: 无法投射“UINavigationController”types的值 出现这个错误是因为addEventControllerembedded到导航控制器中,但是我不知道如何设置segue,以便将destinationViewController设置为NavigationController,还允许将prepareForSegue方法中的variables传递给addEventController 那么我将如何使用Swift来做到这一点? 我非常感谢你的帮助和时间,你可以提供回应。 它帮助很多

使用“下一步”作为返回键

我使用“返回键”的“下一步”值来获取下一步button来代替完成button,但(显然)按下它不会自动移动到我的看法中的下一个UITextField。 什么是正确的方法来做到这一点? 我看到了很多答案,但任何人都有一个快速的解决scheme?

尝试在Swift中将Firebase时间戳转换为NSDate

我试图在Swift应用中使用Firebase时间戳。 我想将它们存储在我的Firebase中,并将它们用作本机NSDate对象。 文档说他们是unix时代,所以我试过了: NSDate(timeIntervalSince1970:FirebaseServerValue.timestamp) 没有运气。 这个: FirebaseServerValue.timestamp 回报 0x00000001199298a0 根据debugging器。 通过这些时间戳的最好方法是什么?

UITableViewRowAction标题作为图像图标而不是文本

我想把图标(图像),而不是文本Swift中的tableviewCell中的滑动操作。 但我不怎么把图像,而不是标题文字? 我的代码如下: func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? { var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share" , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in // 2 let shareMenu = UIAlertController(title: nil, message: "Share using", preferredStyle: .ActionSheet) let twitterAction = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default, handler: nil) let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, […]

您如何正确地从Firebase按时间顺序sorting数据

我试图从Firebase订购我的数据,所以最近的post是在顶部(如Instagram),但我不能让它正常工作。 我应该使用服务器时间戳吗? 有没有“createdAt”字段? func getPosts() { POST_REF.observeEventType(.Value, withBlock: { snapshot in guard let posts = snapshot.value as? [String : [String : String]] else { print("No Posts Found") return } Post.feed?.removeAll() for (postID, post) in posts { let newPost = Post.initWithPostID(postID, postDict: post)! Post.feed?.append(newPost) } Post.feed? = (Post.feed?.reverse())! self.tableView.reloadData() }, withCancelBlock: { error in print(error.localizedDescription) }) […]

推送通知不在iOS 10上收到,但在iOS 9和之前的版本上

我有几个在Swift 2.2中编写的应用程序,使用Xcode 7.3进行编译,并且在App Store上运行。 这些应用程序利用推送通知,并在iOS 9.3及更早版本中正常工作。 但是,在已升级到iOS 10的设备上,我的应用程序不会收到任何推送通知。 仍在运行iOS 9的设备仍在接收通知。 认为这可能是一个证书或权利问题,我已经尝试了以下:升级我的应用程序Swift 2.3,添加了APS环境权利,并编译在Xcode 8,但这没有什么区别。 在我的AppDelegate我仍然有现有的方法注册推送通知,其中包括: let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories:nil) application.registerUserNotificationSettings(notificationSettings) 即使在iOS 10上,这个注册似乎也是成功的,因为应用程序didRegisterForRemoteNotificationsWithDeviceToken然后被调用,所以我从APNS接收一个令牌。 问题是,当我发送一个推送通知到这个设备, 应用didReceiveRemoteNotification永远不会被调用。 现在, 这里说,UIApplicationDelegate上的方法已被弃用在iOS 10上,我应该实现userNotificationCenter( :didReceive : withCompletionHandler :)和userNotificationCenter( :willPresent: withCompletionHandler 🙂 问题是,我不是只针对iOS 10.我仍然需要应用程序在iOS 8和9上工作,所以我怀疑这是实现这些方法的正确方法。 如何获取现有应用程序的推送通知,以继续在已升级到iOS 10的设备上工作? 我是否需要重写代码? 我是否需要更新一些证书或授权,并在Xcode 8中用一些“新”设置重新编译?

GM发布的Xcode 6编译

我刚刚下载了Xcode 6的GM版本,它不会编译这个错误: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 有想法该怎么解决这个吗?