2018-10-22         Honey

List UIButtons in a Grid view without using CollectionView

I'm going to have a squared grid of UIButton objects. Each of these UIButtons is referenced to an unique option and id coming from an array API.Example of the option APIoptions = ( { name = Color; "option_id" = 16; "product_option_id" = 1324; "product_option_value" = ( { image = "example.com/image.jpg"; name = red; "option_value_id" = 104; price = 0; "price_prefix" = "+"; "product_option_value_id" = 4650;...

 ios                     1 answers                     63 view
 2018-10-22         Xavier

Swift 4 Xcode 9 Take Screenshots of a View and Save them

I'm trying to put a Button into my App which should take a Screenshot of a View.I tried different things, but nothing worked (Always got "Thread 1: Signal SIGABRT" as error) I make a little extension of UIImage with option to transform UIView into UIImage and then to scale image in exactly size that you need. Now you can just init your UIImage with your view line var image = UIImage(view:myView)extension UIImage { func imageWithImage(scaledToSize newSize:CGSize) -> UIImage?{ UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0); self.draw(in: CG...

 ios                     1 answers                     81 view
 2018-10-22         Cleveland

How to parsed all the data in JSON?

First issue I addressed I am working on an APIService using Alamofire, I tried to print the response and the I got the data successfully, but unfortunately the data from JSON turns to nil when I parse it to the attendees Object. How can I reflect the data from json to the attendees object? Second Issue I solved the 1st issue, after all the debugging I had. The codes I used was written in my answer below. I parsed data from JSON going to attendees but as I checked only the first array was fetch. How can I get all the data inside the JSON? Hope you can help me. Thank you.fu...

 ios                     2 answers                     66 view
 2018-10-22         Mavis

How to get key Value from post webservice API and fetch that to tableview

I got data from API in this format but the problem is that I want to get all questions and answers from the API but whenever I try to get the value by using the key value it returns nil value and application crashesthis is my api data looks like after getting into a dictionaryhere's my code for getting data from APIAlamofire.request(url, method: .post, parameters: parameters,encoding: JSONEncoding.default, headers: header ).responseJSON { response in switch response.result { case .success: print(response) if let result = response...

 ios                     1 answers                     67 view
 2018-10-22         Devin

Parsing JSON, data turns Nil in API Service Using Alamofire

I was about to get data from API, when I tried to print the response from the API, it printed successfully, and when I tried to print the data from an Object, it also printed successfully, but when I checked the variable attendees in my APIService, the value is always nil,that's why when passing the value in UI it also turns into nil. How can I get the data from JSON to reflect to attendess in Api Service. I am too puzzled regarding this. Please help me. Thank you.getParticipant Function in API Service func getParticipants(passcode: String, participan...

 ios                     1 answers                     68 view
 2018-10-22         Roderick

Cant upload multiple files from array with Alamofire

Im trying to upload multiple image and video from library to url. evertying works fine except , response turns only one file. I choose two different image for experiment but response is only for last image in array. here is my upload func.. func upload() { var mediaData = Data() var fname = "" var mimetype = "" let url = URL(string: "https://myurl.com/api/attachment/upload") let headers: HTTPHeaders = [ "Authorization": "my Authorization Token", "Content-type": "multipart/form-data" ] Alamofire.upload(multipartFormData:...

 ios                     2 answers                     69 view
 2018-10-22         Dinah

Why does the uploadprogress for Alamofire never reach a completion of 1.0 during upload?

I am able to successfully upload files using alamofire. However, I am trying to track the progress of the upload. What I am finding is that, although the upload is successful, as I can see my files successfully uploaded on to the server, the progress tracker never reaches 1.0. It tends to end between 8.00 - (under 1.0) but never reaching 1. This presents problems as I need to handle the completion of the file upload. Alamofire.upload( multipartFormData: { multipartFormData in for(key, value) in sendParamters{ multipartFormData.append((va...

 ios                     1 answers                     70 view
 2018-10-22         Lilith

Check for response status without Alamofire

I followed a tutorial to how fetch something from Firebase. The guy in the video said you maybe should check for the response status of 200 (HTTP OK).What are the benefits from checking this and is there a way without Alamofire?Code looks like this:guard let url = URL(string: profileImageUrl) else { return }URLSession.shared.dataTask(with: url) { (data, response, err) in if let err = err { print("Failed to fetch the profile image:", err); return } //check for response status here guard let data = data else { return } let image = UIImage(data: data) DispatchQu...

 ios                     1 answers                     71 view
 2018-10-22         Susie

Alamofire - Bad request

I am afraid I cannot share the API url. But I have checked on Postman, it works. It is a POST request and following is the response : { "user_key": "b0aebdedb15e2beaaf479ca3c4f8227e8e970681"} Postman screenshot : In code, this is the request I am making using Alamofire : Alamofire.request("some url", method: .post, parameters: params, encoding: URLEncoding.httpBody, headers: ["Content-Type":"application/json"]) .responseObject { (response: DataResponse<User>) in let userResponse = response.result.value print("") }Bu...

 ios                     1 answers                     72 view
 2018-10-22         Drew

Autoshrinking text size for multiple ui labels

I have five ui labels for one view. All of them have variable text content. To prevent truncating I have to use Autoshrink text size. My ui labels are aligned in x axis top to bottom. The problem is; when autoshrinking, all ui labels have different font sizes.Is there a way to equalize font sizes of all ui labels when autoshrink. I use interface builder autolayout constraints.Thank you. You could loop through your labels, find the smallest text size and then set that text size to all of them. That way, you know they'll all fit and have the same text size. You would have ...

 ios                     1 answers                     73 view
 2018-10-22         Lyndon

Swift 4, iOS how to detect label height after added string value

in UICollectionView my cell's size must be 150+label.height. Now I'm using custom layout to calculate height = 150 if image exists inImageView if not height = 100. It's easy. But how to calculate label.height when i don't know what text i'll fetch from Api? Is there any function to get that?customLayout.swiftlet photoHeight = delegate.collectionView(collectionView, heightForPhotoAtIndexPath: indexPath) > 0 ? 150 : 100let height = cellPadding * 2 + CGFloat(photoHeight) + (labelHeight??????) You can calculate label height using below function extension UILabel { func...

 ios                     1 answers                     76 view
 2018-10-22         Elma

Realm model contains property but not found it at runtime

I am getting error as below Invalid property name , reason: 'Property 'IsRecordDeleted' not found in object of type 'MyCustomModel'Where as my Model is as Under @objcMembers public class MyCustomModel : Object {dynamic var Id : String = ""dynamic var ProductId : String? = ""dynamic var IsRecordDeleted : Bool? = falsedynamic var ProductBarcode : String? = ""override public class func primaryKey() -> String? { return "Id"}}and I am making query like this :let mSavedItems = mDbHelper.realmObj.objects(MyCustomModel.self).filter("IsRecordDeleted = false")What cou...

 ios                     2 answers                     77 view
 2018-10-22         Matthew

Push notifications and token device in Swift

I am working on an App that need to know the device token to send notification to the users when they give their authorization.The first time the system ask the authorization for notification. If user say "allow" the system calls for me the method didRegisterForRemoteNotificationsWithDeviceToken and in the body of this method I write in UserDefaults the device token.This is the flow:1) System ask for permission2) in didFinishLaunchingWithOptions (inside AppDelegate) I call this method in my class that manage the Notification Framework: func registerForPushNotifications() ...

 ios                     1 answers                     6 view
 2018-10-22         Gabriel

UITableView does not show data correctly in my custom cell UILabel and reuse problem

I create my custom cell class and design my user interface with the code and constraints (I have 2 UILabels that hold my data in each row). I register my customcell class in the main viewController and load data in the tableview. The problem is one of my UILabels fills with data but the second one not show its data until I scroll the table view or click right on that row. See images.Before ScrollAfter scrollHere is my code:class ProjectDetailsCustomCell: UITableViewCell { var key : String? var value : String? var keyContainerView : UIView = { var container...

 ios                     1 answers                     8 view
 2018-10-22         Jane

Downcasting Any? to UIBarButtonItem

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "detailSegue" { let indexPath = tableView.indexPathForSelectedRow! let card = cards[indexPath.row] let detailTableViewController = segue.destination as! DetailTableViewController detailTableViewController.card = card detailTableViewController.picture = card.image } else if segue.identifier == "addEditSegue" { let addEditTableViewController = segue.destination as! AddEditTableViewController let buttonPressed = sender as? UIB...

 ios                     1 answers                     9 view
 2018-10-22         Susan

How can i add multiple HTML files to WebKit View?

IntroductionI'm designing a historical application.I want to add multiple HTML files into WebKit View. I don't have any idea how to do this.ExampleWhen I click to "Button 1" webkit loads "file1.html". I didn't write anything about code I am quite confused. Any help would be appreciated. Well, there is a lot of ways to do it but I'm gonna give an example for easiest one. Just create a method for loading .html file and invoke or call it under action button.For example : import UIKitimport WebKitclass ExampleController: UIViewController {@IBOutlet weak var myButton: UIButto...

 ios                     1 answers                     11 view

Page 1 of 4132  |  Show More Pages:  Top Prev Next Last