评估拍照事物的最佳方法是哪一种?

我的应用程序应该使用欧元硬币作为参考来估计对象的长度(以毫米为单位)。 这是一个截图示例: 为了得到被拍摄的硬币的直径,我首先计算出通过这三个点的圆的方程 x^2 + y^2 + ax + by + c = 0 然后我有直径 2 * square_root((a/2)^2 + (b/2)^2 -c) 。 最后我可以用下面的比例来得到红笔的长度: /* length_estimated_pen (mm) : distance_green_pins (points) = real_diameter_coin (mm) : diameter_on_screen (points) */ let distanceGreen:Double = Double(sqrt(pow(self.greenLocationA.center.x – self.greenLocationB.center.x, 2.0) + pow(self.greenLocationA.center.y – self.greenLocationB.center.y, 2.0))) let estimatedMeasure:Double = (distanceGreen * Double(ChosenMeter.moneyDiameter)) / […]

将自定义图像设置为UIBarButtonItem,但它不显示任何图像

我想将自定义图像设置为UIBarButtonItem,但它只显示一个矩形框,并不显示实际的图像。 func setupBrowserToolbar() { let browser = UIToolbar(frame: CGRect(x: 0, y: 20, width: self.view.frame.width, height: 30)) //configuration返回组件 let path = NSBundle.mainBundle().pathForResource("back", ofType: "png") let urlstr = NSURL(fileURLWithPath: path!) let data = NSData(contentsOfURL: urlstr) let btnback = UIBarButtonItem(image: UIImage(data: data!), style: UIBarButtonItemStyle.Plain, target: self, action: Selector("backClicked:")) //分割button1 let btngrap1 = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil) […]

模糊使用下标xcode 7.1

我有这个代码: var jsonResult = (try! NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers)) as! NSDictionary var count = jsonResult["levels"]!.count as Int for var i=0; i<count; ++i { let obj = jsonResult["levels"]![i] as! NSDictionary … } 在最后一行,我收到这个错误: 下标使用不明确 我该如何解决这个问题? 这段代码已经工作了一段时间,但随着升级到Xcode 7.1它打破了,停止工作。

我想在NSDateComponents类中获得四分之一的值

我想从指定的date获得四分之一的价值。 (*datevariables) 所以。 我已经做了下面的代码并运行。 但是,季度值是零。 为什么季度价值为零? 问题在哪里? 请先进的人的build议。 NSDateComponents *comp1 = [[NSDateComponents alloc] init]; [comp1 setYear:2012]; [comp1 setMonth:6]; [comp1 setDay:1]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *date = [gregorian dateFromComponents:comp1]; <== want to get a quarter value. unsigned int unitFlags = NSYearCalendarUnit | NSQuarterCalendarUnit | NSMonthCalendarUnit | NSWeekOfYearCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit […]

如何注册一个应用程序来响应一个自定义的URLscheme打开请求?

喜欢这个: NSString *stringURL = @"appname://"; NSURL *url = [NSURL URLWithString:stringURL]; [[UIApplication sharedApplication] openURL:url]; 我稍微记得有必要给Info.plist写一个值键。 怎么样?

FirebaseStorage:如何删除目录

当我试图删除一个目录时,FirebaseStorage总是返回错误400 ,例如下面的东西总是返回错误400 。 let storageRef = FIRStorage.storage().reference().child("path/to/directory") storageRef.deleteWithCompletion { (error) in print("error: \(error)") // always prints error code 400 } 但是,删除文件可以正常工作,例如,不会返回错误: let storageRef = FIRStorage.storage().reference().child("path/to/file.jpg") storageRef.deleteWithCompletion { (error) in print("error: \(error)") // works fine, error is nil } 我在这里做错了什么? 我不认为它不被FirebaseStorage支持,因为从一个目录逐个删除文件将是非常跛脚的(特别是如果所述目录有这些的100个或1000个)。

UIStackView分发填充同样

所以,我有一个包含四个(4) UIView的UIStackView 。 如果我移除这些UIView的一个,其他三个将填充UIStackView的整个空间。 我的问题: 我怎样才能在UIView上添加一个最大高度,使它不会填充UIStackView的整个空间,即使分布是平等的填充? 我读了一些关于添加约束的东西,但是我无法使其工作。 顺便说一句,我正在使用swift。 谢谢。

无法在iTunes Store中存档

当试图上传我的应用程序,我得到的错误:“你必须提供一个CFBundleIdentifier这个请求”。 info.plist,“General Identity”,iTunesConnect和App ID(Apple Developer)中的标识符(UTI格式)都是相似的。 在applicationdidFinishLaunchingWithOptions中获取CFBundleIdentifier时:我得到相同的结果。 我已经改变了项目名称,也许它有什么关系呢? 有什么build议么? 谢谢! 的Info.plist

从编程方式拨号USSD代码

如何以编程方式拨打iphone的USSD代码? 我search了一下,发现iOS 7已经为了安全原因而阻止了USSD代码的使用,而在iOS7中我们可以通过手动方式拨打USSD代码。 任何人都有一个想法,我们可以通过编程方式调用USSD: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:\*123* <2334555>#"]] ?

为什么我的string在iOS应用程序中可能不安全?

我正在初始化一个可变的string,然后logging如下。 NSMutableString* mStr = [[NSMutableString alloc] init]; mStr = (NSMutableString*) someTextFieldIbOutlet.text; NSLog((NSString *) mStr); 代码工作并运行,但我得到一个奇怪的警告(黄色): Format string is not a string literal (potentially insecure). 为什么?