Tag: 迅速

获取一个UILocalNotification每周开火

我已经设置了一个本地通知来触发。 我想知道如何让它在每周的同一时间,例如周一上午9点​​重复。 这是我的代码到目前为止: @IBAction func scheduleLocal(sender: UIButton) { guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else { return } if settings.types == .None { let ac = UIAlertController(title: "Cant Schedule", message: "No Permission", preferredStyle: .Alert) ac.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil)) presentViewController(ac, animated: true, completion: nil) return } let notification = UILocalNotification() notification.fireDate = NSDate() notification.alertBody = […]

UIButton自动调整button字体大小Swift

我尝试做出一些测验,并对我的答案button有问题。 简单的事实:文本太长,我尝试使用不同的方法自动调整单元格。 我目前的状态: for btn in btnArr{ btn.titleLabel!.minimumScaleFactor = 0.3 btn.titleLabel!.numberOfLines = 0 btn.titleLabel!.adjustsFontSizeToFitWidth = true btn.titleLabel?.baselineAdjustment = UIBaselineAdjustment.AlignCenters //btn.contentEdgeInsets = UIEdgeInsets(top: 3.0,left: 3.0,bottom: 3.0,right: 3.0) } 我希望有人有另一种select,使我的工作:) 问候,帕特里克 编辑: self.view.addConstraint(NSLayoutConstraint(item: btn.titleLabel!, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: btn, attribute:NSLayoutAttribute.Height, multiplier: 0.99, constant: 0))

iOS忽略enqueueSampleBuffer,因为状态失败

当我从这里重新启动应用程序: https : //github.com/zweigraf/face-landmarking-ios相机的图片不会出现,并打印错误:“忽略enqueueSampleBuffer,因为状态失败”。 这个问题可能是在SessionHandler.swift的captureOutput中

如何从AVFoundation获得光照价值?

我使用Swift 3并使用相机AVFoundation 谁知道有什么方法可以知道光的能力? 我知道其中一种方法是使用环境光线传感器,但不鼓励,最终应用程序不允许在市场上 我发现问题非常接近我需要的 检测iPhone是否在黑暗的房间里 那家伙解释说,我可以使用ImageIO framework, read the metadata that's coming in with each frame of the video feed – (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { CFDictionaryRef metadataDict = CMCopyDictionaryOfAttachments(NULL, sampleBuffer, kCMAttachmentMode_ShouldPropagate); NSDictionary *metadata = [[NSMutableDictionary alloc] initWithDictionary:(__bridge NSDictionary*)metadataDict]; CFRelease(metadataDict); NSDictionary *exifMetadata = [[metadata objectForKey:(NSString *)kCGImagePropertyExifDictionary] mutableCopy]; float brightnessValue = [[exifMetadata objectForKey:(NSString *)kCGImagePropertyExifBrightnessValue] […]

你可以在NSObject类中添加Target到UIButton吗?

你怎么addTarget到一个NSObject类的UIButton? 还是那个class不行? class Support: NSObject { func helpButton(viewController: ProfileVC) { let helpButton = viewController.helpButton helpButton.frame.size = CGSizeMake(35.0, 35.0) helpButton.layer.cornerRadius = helpButton.frame.height/2 helpButton.layer.borderWidth = 0.5 helpButton.layer.borderColor = lightColoredFont.CGColor helpButton.setTitle("?", forState: .Normal) helpButton.setTitleColor(lightColoredFont, forState: .Normal) helpButton.titleLabel?.font = fontSmaller helpButton.addTarget(self, action: Selector("showOptions"), forControlEvents: .TouchUpInside) helpButton.center.y = viewController.logoutButton.center.y helpButton.frame.origin.x = (viewController.view.bounds.width – viewController.logoutButton.frame.maxX) viewController.view.addSubview(helpButton) } func showOptions() { print("showing") […]

使用NotificationCenter Observer处理asynchronous请求

这个问题也有类似的问题,所以我很抱歉,但是没有人能够帮助我。 我正努力将这个asynchronous请求的值从完成处理程序返回给Firebase。 我从Firebase中检索的值是一个数组,它确实存在。 但 以下是我向Firebase发出请求的function: class SearchManager { var searchResults = [String]() var listOfMosaics = [String]() // Retrieves company list from Firebase func getMosaicTitles(completionHandler: @escaping (_ mosaics: [String]) -> ()) { Database.database().reference().child("mosaics").observeSingleEvent(of: .value, with: { (snapshot) in guard let allMosaics = snapshot.value as? [String] else { print("unable to unwrapp datasnapshot") return } completionHandler(allMosaics) }) } […]

与prepareForSegue错误“”意外地发现零,而解包一个可选值“”

我试图通过prepareForSegue函数从PFTableViewCell传递数据到下一个视图控制器(细节)。 我想我已经把正确的代码,但是当我运行应用程序,然后单击单元格,我的应用程序崩溃,我得到这个消息“意外地发现零,同时解开可选值”。 我已经尝试了prepareForSegue函数传递数据的许多变化,但它永远不会出现在下一个视图控制器。 在我的FirstViewController中,我写了这个代码: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "Detail" { if let destination = segue.destinationViewController as? ResponseViewController { let path = tableView?.indexPathForSelectedRow! let cell = tableView!.cellForRowAtIndexPath(path!) as! Post destination.name = (cell.name.text!) destination.message = (cell.message.text!) } 以下是显示在ResponseViewController中传递的数据的代码: var name = String?() var message = String?() @IBOutlet weak var userName: UILabel! […]

长按Google地图

帮我解决问题。 我试图在Google地图上长时间跟踪地图,但是我无法做到这一点。 这是我的代码的一个例子: import UIKit import GoogleMaps class ViewController: UIViewController { @IBOutlet var mMap: GMSMapView! var longPressRecognizer = UILongPressGestureRecognizer() @IBAction func longPress(_ sender: UILongPressGestureRecognizer) { testTextview.text = "You tapped at YES" } override func viewDidLoad() { super.viewDidLoad() longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.longPress)) longPressRecognizer.minimumPressDuration = 0.5 mMap.addGestureRecognizer(longPressRecognizer) mMap.isMyLocationEnabled = true mMap.settings.compassButton = true mMap.camera = […]

为什么在我打开localNotification中的string数组时返回nil?

notificationTime = ["2016-05-26 16:27:17 +0000","2016-05-24 13:29:37 +0000"] var num = 0 func locaNotification(num:Int) { let dateFormatter = NSDateFormatter() dateFormatter.locale = NSLocale.currentLocale() dateFormatter.dateStyle = NSDateFormatterStyle.FullStyle var dateAsString = notificationTime[num] dateFormatter.dateFormat = "yyyy-MM-dd HH:mm" var newDate = dateFormatter.dateFromString(dateAsString)! 它在这里展开时返回nil,newDate =上一行代码后的零! var arr = UIApplication.sharedApplication().scheduledLocalNotifications for localN:UILocalNotification in arr! { var notificationFireDate:NSDate = localN.fireDate! if notificationFireDate == newDate […]

error handling程序未被调用promise

我有一个服务,当我input错误的login凭据失败。 但是,我的承诺error handling程序不会被调用。 我似乎并没有明白我的代码有什么问题,所以errorcallback从来没有达到过。 服务 func loadRepositories() -> Promise<[Repository]>{ return Promise { fullfill, reject in manager.request(Method.GET, baseURL + "/api/1.0/user/repositories") .authenticate(user: username, password: password) .responseArray { (response: Response<[Repository], NSError>) in switch response.result{ case .Success(let value): fullfill(value) case .Failure(let e): // The breakpoint here is reached. reject(e) } } } } 处理 firstly{ service!.loadRepositories() }.then { repositories […]