[Solved] How to load Custom cell (Xib) in UITableview using Swift

[ad_1] import UIKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { //MARK:- Sample Data Array to load in TableView let sampleArrray: \[String\] = \[“val1”, “val2”, “val3”, “val4”, “val5”] //MARK:- Cell reuse identifier let cellReuseIdentifier = “cell” //MARK:- UITableView outlet @IBOutlet var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() // Registering the custom cell self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellReuseIdentifier) // … Read more

[Solved] sendSynchronousRequest is deprecated in ios 9 [duplicate]

[ad_1] This is a working example, You should use NSURLSession, with Request. func testPost(sender: UIButton) { let session = NSURLSession.sharedSession() let request = NSMutableURLRequest(URL: NSURL(string: “http://localhost:8080/iOSServer/ios/helloworld/swiftCalculator”)!) request.setValue(“application/x-www-form-urlencoded”, forHTTPHeaderField: “Content-Type”) request.HTTPMethod = “POST” let d = “4” let data = “x=4&y=\(d)” request.HTTPBody = data.dataUsingEncoding(NSASCIIStringEncoding) let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in if let error … Read more

[Solved] How do I capture screen view and share it? [closed]

[ad_1] You can add share button var shareButton: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: “shareButtonPressed:”) self.navigationItem.rightBarButtonItem = shareButton and populate share options func shareButtonPressed(sender: AnyObject) { NSLog(“shareButton pressed”) let stringtoshare: String = “This is a string to share” //add current screen shot image to share let imagetoshare = captureScreen() let activityItems: [AnyObject] = [stringtoshare, … Read more

[Solved] how to encode this JSON reply from Food API

[ad_1] You have some response and this response’s value is most likely of type Data, so you need to decode it to some Swift type. Since Swift 4 you can easily use Decodable protocol for decoding Data to your custom model conforming to this protocol. So let’s create simple struct for simple json Json: let … Read more

[Solved] ios UIView for complete viewController frame [closed]

[ad_1] -(UIView *) returnGradientView { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = view.bounds; //change your color as you like, I have used black and white gradient.colors = @[(id)[UIColor blackColor].CGColor, (id)[UIColor whiteColor].CGColor]; [view.layer insertSublayer:gradient atIndex:0]; return view; } Edit this will create an gradient view, upper side … Read more

[Solved] How to put the burger icon in a UIBarButtonItem?

[ad_1] You’ll want to use the UIBarButtonItem constructor init(image: UIImage?, style: UIBarButtonItemStyle, target: Any?, action: Selector?) an example usage would be: self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: “burger_icon”), style: .plain, target: self, action: #selector(self.someMethod)) In this example “burger_icon” is the name of the image asset in your project and self.someMethod is the method that is called when … Read more

[Solved] Swift, Pass data from popover controller to previous controller [closed]

[ad_1] You can use custom delegate method to fill the value. class PopupviewController { weak var delegate: filleTextViewDelegate? func calldelegate () { delegate?.fillTextview(filledData) } } protocol filleTextViewDelegate : class { func fillTextview(filledData: String) } class CurrentViewController :filleTextViewDelegate { func fillTextview(filledData: String) { textView.text = filledData } } [ad_2] solved Swift, Pass data from popover controller … Read more

[Solved] how to use two CollectionView on same view controller scroll one by one [closed]

[ad_1] You can add two collection view in a single view controller by dragging it. but you have to validate UIcollection view like func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var cell = HomeCollectionViewCell() if(collectionView == self.collName1) { cell = collName.dequeueReusableCellWithReuseIdentifier(“CellIdentifier”, forIndexPath: indexPath) as! HomeCollectionViewCell } else if(collectionView == self.collName2) {} return cell … Read more

[Solved] What is the use of the “of” keyword in Swift? [duplicate]

[ad_1] In this case, “of” is the label for the argument called “name”. If you were to call this function, it would be student(of: “Mathematics”) However inside the student function, you would get it’s value with “name” func student(of name: String) -> String { print(name) // TODO: Do something and return } Just a suggestion, … Read more