swift3

iOS Swift App with more photos: Performance and Storage suggestions

廉价感情. 提交于 2019-12-13 12:51:27
问题 I am trying to develop an iOS application where users upload photos, can someone please suggest best and efficient ways to handle the storage and performance issues. Consider each user will be uploading around 300 photos in a month (worst case scenario). My basic idea was to use Document Directory locally to store images and then sync it with FireBase. I am a beginner in developing apps in iOS, willing to know the best practices to start my app. Thank you 回答1: You can do it next way: 1)

Call both of After and Before Method in UIPageViewController when swim for forward in Swift 3 iOS

瘦欲@ 提交于 2019-12-13 12:23:49
问题 I made UIPageViewController with datasource array and it's works correctly. But when swiping to right for forwarding call both of After and Before methods. My codes is here: import UIKit class MainPageViewController: UIPageViewController,UIPageViewControllerDataSource { override func viewDidLoad() { super.viewDidLoad() self.dataSource = self initUPageVC(idx:0,isAnimate:false,direction: UIPageViewControllerNavigationDirection.forward) } func pageViewController(_ pageViewController:

Swift 3 - How do I improve image quality for Tesseract?

你离开我真会死。 提交于 2019-12-13 12:22:55
问题 I am using Swift 3 to build a mobile app that allows the user to take a picture and run Tesseract OCR over the resulting image. However, I've been trying to increase the quality of scan and it doesn't seem to be working much. I've segmented the photo into a more "zoomed in" region that I want to recognize and even tried making it black and white. Are there any strategies for "enhancing" or optimizing the picture quality/size so that Tesseract can recognize it better? Thanks! tesseract.image =

How to make simultaneous https requests in Swift 3

有些话、适合烂在心里 提交于 2019-12-13 12:15:54
问题 I'm having problems to execute a https requests, if the request don't have any error i never get the message, this is a command line tool application and i have a plist to allow http requests, i always see the completion block. typealias escHandler = ( URLResponse?, Data? ) -> Void func getRequest(url : URL, _ handler : @escaping escHandler){ let session = URLSession.shared var request = URLRequest(url:url) request.cachePolicy = .reloadIgnoringLocalCacheData request.httpMethod = "GET" let

How can I reset the timer after a certain duration?

空扰寡人 提交于 2019-12-13 10:40:58
问题 I have set a timer in my code below. How can I make the timer reset every time it reaches a given duration say, 7 seconds? class SpriteGroup { var sprites : [Sprite] var isVisible : Bool var startTime: TimeInterval = 0.0 var currentTime: TimeInterval = 0.0 init(sprites : [Sprite], isVisible: Bool, pos: CGPoint) { self.sprites = sprites ... startTime = Date.timeIntervalSinceReferenceDate Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.advanceTimer(timer:)),

unexpected non-void return value in void function Swift 4

痞子三分冷 提交于 2019-12-13 10:35:05
问题 Iam trying to return the response body from the switch statment in ECPLogin but it give me this error "unexpected non-void return value in void" even though i declare the function gotourl() -> String in line 33. Please advice. Here is my code import UIKit import SwiftECP import XCGLogger class ViewController: UIViewController { @IBOutlet var UsernameField: UITextField! @IBOutlet var passwordField: UITextField! override func viewDidLoad() { super.viewDidLoad() } @IBAction func _Login(_ sender:

Swift - Group elements of Array by value (2 by 2, 3 by 3, etc…)

为君一笑 提交于 2019-12-13 09:46:06
问题 EDIT: I'm not asking a function to count an occurence. I'm asking a function to count an occurence 2 by 2 , 3 by 3 , 10 by 10 , etc... this is my problem I have an array of scores, lets say: [2,2,3,4,4,4,4,5,6,6,8,8,8,9,10,10] I would like to have a function that transform this Array into a Dictionary [Int: Int]() to have something like that: func groupArrayBy(array: Array<Int>, coef: Int) -> Array<Int, Int>{ // if coef = 2 -> 2 by 2, count occurence // Transform the array to: // [2: 3, 4: 5,

iOS Charts, wavy lines

杀马特。学长 韩版系。学妹 提交于 2019-12-13 09:30:50
问题 Let's get straight to the point: I started to use iOS Charts by Daniel Gindi, but I just can't reproduce this wavy lines in my line chart (and please notice that this image is picked form the repository of iOS charts!) All I get is just this, simple straight lines with no curves And this is the code in viewDidLoad that I used for showing that: let ys1 = Array(1..<10).map { x in return sin(Double(x) / 2.0 / 3.141 * 1.5) } let ys2 = Array(1..<10).map { x in return cos(Double(x) / 2.0 / 3.141) }

Getting error while setting alpha of UIView Swift 3 [duplicate]

和自甴很熟 提交于 2019-12-13 09:28:08
问题 This question already has answers here : What does “Fatal error: Unexpectedly found nil while unwrapping an Optional value” mean? (11 answers) Closed 2 years ago . I'm making quiz app and when I want to change value of alpha of my UIView I'm getting error fatal error: unexpectedly found nil while unwrapping an Optional value , before it warms fine but I'm remodeling my app and I think that I delete something or change by mistake. I don't want to put all my code here because it is quiet large

Custom Keyboard Storyboard with Xcode 8 beta

和自甴很熟 提交于 2019-12-13 09:27:14
问题 I'm having some problems designing my custom keyboard from the storyboard in Xcode 8 beta 6. For some reason when I launch the keyboard on a iOS 10 device this is the result: This is how i design it in the Storyboard, Top View: Bottom View: So it displays only the height of the bottom view. I don't have this problem with iOS 9. Any ideas on what is going wrong? UPDATE : this it's how the keyboard gets loaded in iOS 9: UPDATE 2: Even creating the view programmatically this way in viewDidLoad()