swift3

Frontmost UIView with TapGestureRecognizer not receiving touches

我怕爱的太早我们不能终老 提交于 2019-12-12 01:25:45
问题 I'm trying to add a (background) mask view to the front most window in my iOS app. On that mask view I want to add a UITapGestureRecognizer that will dismiss the mask view. Ultimately, I want to display a popup in the middle (i.e. my mask view is a faded background for the popup), but for now I'm just having trouble getting my background to dismiss as expected. The code looks like this: I get the front most window. I create the background view and add alpha. Then I add my gesture recognizer,

Conversion from Swit2.3 to Swift3 cause “Terminating with uncaught exception of type NSException”

痞子三分冷 提交于 2019-12-12 01:24:22
问题 Here is the code I want to convert from Swift2.3 to Swift3: AWSCloudLogic.defaultCloudLogic().invokeFunction(functionName, withParameters: parameters, completionBlock: {(result: AnyObject?, error: NSError?) -> Void in if let result = result { dispatch_async(dispatch_get_main_queue(), { print("CloudLogicViewController: Result: \(result)") //self.activityIndicator.stopAnimating() //self.resultTextView.text = prettyPrintJson(result) }) } var errorMessage: String if let error = error { if let

Can I use dispatch group not in a loop?

送分小仙女□ 提交于 2019-12-12 01:14:58
问题 Say I have 3 different asynchronous tasks I want to get done before calling some function. I'm aware of using dispatch groups to do such a thing if those tasks were in a loop, var dispatchGroup = DispatchGroup() for task in tasks { dispatchGroup.enter() DoSomeTask { (error, ref) -> Void in dispatchGroup.leave() } } dispatchGroup.notify(queue: DispatchQueue.main, execute: { DoSomeFunction() }) However, I'm confused on how you'd do this if those tasks were all in the same function but didn't

UIProgressView is not updating inside UICollectionView in Swift3 iOS

こ雲淡風輕ζ 提交于 2019-12-11 18:51:19
问题 I am new to Swift3. I am uploading Video to Amazon S3 server from my Application and for each Video I have set one progress view. When I am adding a video that time my ProgressView is updating but my problem is when I am going back from the screen and come again then ProgressView is not updating. I checked using breakpoint then my Collection View cellForItemAt method is invoking, but progress view is not updating. I have added UIProgressView using Custom cell. Here is my code: public func

Swift: Problems with custom UIView.transition?

ぃ、小莉子 提交于 2019-12-11 18:30:03
问题 Ok, I have looked through https://developer.apple.com/videos/play/wwdc2013/218/ and SO questions similarly trying to make custom transitions with a tab bar controller and its viewcontrollers but Im running into confusion after figuring out the main steps here. I need to know how (meaning example code would be really helpful) to call a custom UIView.transition OR just have a custom option in UIView.transition . I need to use this to make a sliding/modal -mimicking transition between tabs in my

How we can pass default null value in parameter list of dictionary [String:String] while posting a request to server ? Swift3

我的未来我决定 提交于 2019-12-11 17:49:52
问题 In some case i have to post null values to server either as a default value or as a parameter's value.I tried many ways but it didnt work.I'm using Alamofire for posting a request.Please help. Method-1 var empty : String = "" let parameters = ["User-Id":userId,"search_cat": formattedArray ?? empty,"date1":ab ?? empty,"date2" : bc ?? empty,"docname" : empty ] as! [String : String] Method-2 let parameters = ["User-Id":userId,"search_cat": formattedArray ?? "","date1":ab ?? "","date2" : bc ?? ""

Don't reload VC1 when clicking back from CV2 - Swift

空扰寡人 提交于 2019-12-11 17:16:31
问题 I would like to navigate from VC1 (All Restaurant View) to VC2 (Restaurant Details View) and when ill press "Back Button" it shouldn't reload VC1 again. How can I solve this? func clickNameButtonCollectionView(sender: UIButton) { let restaurent_Id = ((self.allRecommendedRestaurent[sender.tag] as AnyObject).value(forKey: "id") as AnyObject) as? Int let obj = self.storyboard?.instantiateViewController(withIdentifier: "ResturantDetailsController") as! ResturantDetailsController obj.restaurent_ID

add some button to GMSMapView (Google Map) and change the image button

拟墨画扇 提交于 2019-12-11 17:07:55
问题 I try but can't show the button Code: btnLokasiSaya = UIButton(frame: CGRect(x: 341, y: 28, width: 100, height: 30)) self.viewMap.addSubview(btnLokasiSaya) StoryBoard: Output: my button is not found in simulation 回答1: In your Main.Storyboard add button outside the mapview as shown below: 来源: https://stackoverflow.com/questions/52440728/add-some-button-to-gmsmapview-google-map-and-change-the-image-button

didRefreshRegistrationToken is not being called if user Don't Allow notifications swift

别来无恙 提交于 2019-12-11 16:55:15
问题 My problem is not being solved after I've tried a lot of questions which might have the solution for this issue: I want to get FCM Token . In AppDelegate.swift I've imported import UserNotifications import Firebase import FirebaseInstanceID import FirebaseMessaging After that I've extended it with UNUserNotificationCenterDelegate, MessagingDelegate and then in didFinishLaunchingWithOptions I've added: if #available(iOS 10.0, *) { // For iOS 10 display notification (sent via APNS)

Swift how to get UIAlertController title height

核能气质少年 提交于 2019-12-11 16:47:54
问题 Currently I'm working on UIAlertController in swift. I'm trying to add an activity indicator to my alert controller. I have found following solution, but when the title is bigger than one line, then spinner and title overlapped. For this I guess, I need to know the height of title label. let spinner = UIActivityIndicatorView(activityIndicatorStyle: .gray) spinner.center = CGPoint(x: 130.5, y: 65.5) spinner.startAnimating() alert.view.addSubview(spinner) Someone please help me with a proper