Posts

Showing posts with the label ios

Parse JSON in Swift 24hours of problems

Parse JSON in Swift 24hours of problems I am really struggling to parse a json file into my iOS app in Swift. I have a JSOn output from an SQL db. I think the formatting is wrong and the data headers are a bit ambiguous but my developer who I hired to create the process is happy with the output. Link below. So in the last 3 days I have read all of the Apple Developer materials on parsing JSON, also watched numerous tutorials which all cover pretty much the same data, and I don't know how much I have read and converted into actual projects which have all failed. I am really needing some guidance here. I have even in a desperate attempt to understand my problem from a different perspective I have looked at how it is done in other languages. This is the latest iteration: func flightData()-> [[String: String]]{ let url = URL(string: "http://35.237.114.234/api/index.php?uid=Bx7faf08A9fYJ7bZCNMUX9EzxYN2") guard let jsonFileURL = Bundle.main.url(forResource: "jso...

Who is calling reloadData method for UITableView

Who is calling reloadData method for UITableView It can sounds weird but I don't understand why my tableView is showing cells. I got array of items that should be shown in cells but I don't run reloadData method of my tableView anywhere in my code. It seems that some of app components or maybe frameworks inside app is calling reloadData method and I want to find out which one? reloadData reloadData How it can be done? why this is a problem? reloadData shouldn't be overridden (there is no reason). – Marek R Jun 30 at 6:35 reloadData the problem is that tableView is showing content before it is properly prepared – moonvader Jun 30 at 7:15 you are barking ...

UISearchBar increases navigation bar height in iOS 11

Image
UISearchBar increases navigation bar height in iOS 11 I have my UISearchBar being part of the navigation bar like: UISearchBar let searchBar = UISearchBar() //some more configuration to the search bar ..... navigationItem.titleView = searchBar After updating to iOS 11 something weird happened to the search bar in my app. On iOS 10 and prior I had my navigation bar looking like: iOS 11 iOS 10 Now with iOS 11 I have: iOS 11 As you can see there is difference in the rounding of the two search bars which does not bothers me. The problem is that the search bar increases the height of the navigation bar. So when I go to another controller it looks weird too: In fact that weird black line's height plus the current navigation bar's height is equal to the height of navigation bar shown in the second picture ... Any ideas how to get rid of the black line and having consistent navigation bar height across all view controllers ? Possible duplicate of iOS...

Swift iOS -How to Switch / Toggle between two UIWindows and make either the keyWindow

Image
Swift iOS -How to Switch / Toggle between two UIWindows and make either the keyWindow I created an additional UIWindow that will get presented on top of the main window. The user presses a button and it transitions over the main window. The user can minimize the additional window and it will sit above the tabBar like it the picture below. They can enlarge it to cover the main window or dismiss it and it gets destroyed. It works fine. I also created a custom action sheet that launches from the bottom of the screen. If the additional window completely covers the main window and the action sheet is launched, it will launch perfectly inside the additional window. If the additional window isn't on the screen it launches perfectly inside the main window. The problem is if the additional window is minimized on screen and I want to launch the action sheet from the main window, the action sheet launches inside the additional window instead, it cannot distinguish between the two. I opened ...

Initial ViewController still showing after segue

Image
Initial ViewController still showing after segue The app I am currently working on requires that I do not use ANY storyboards. Therefore I need to do everything programmatically. One thing I seem to be struggling with is switching between two UIViewControllers. The code I am using to go from VC1 to VC2 is: self.present(signUpVC(), animated: true, completion: nil) And the code I am using to go from VC2 back to VC1 is: self.dismiss() The problem I seem to be facing is that as VC2 is coming up, VC1 is still visible in the background (frame 1): Here is the next frame: This is the final frame of the transition, and as you can see, the initial view is still visible in the background (Frame 3): Is there any way I can fix this issue? Is the background of the view controller clear? Show some code – Scriptable Jun 29 at 22:20 ...

Bundlejs error on release build in Xcode (react-native)

Image
Bundlejs error on release build in Xcode (react-native) For some reason I am getting the following error when building a release version of my application via react-native. *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: t.typeof is not a function. (In 't.typeof("function"==typeof Symbol?Symbol.iterator:"@@iterator")', 't.typeof' is undefined) (/Users/../THEAPP.app/main.jsbundle:11)', reason: 'Unhandled JS Exception: t.typeof is not a function. (In 't.typeof("function...' This is the source of the code that has the above error that I found in my bundlejs file: !(function(e){"use strict";var r,t=e.babelHelpers={};t.typeof="function"==typeof Symbol&&"symbol"===t.typeof("function"==typeof Symbol?Symbol.iterator:"@@iterator")? I have tried both of these methods of a release build: react-native bundle --entry-file index.js --platfor...

Firestore & Swift

Firestore & Swift Currently I'm working on a project which uses Firestore. The problem I am facing is as follows: I want to fill a collectionview with data from Firestore, the data is an image + a label. Once a user clicks on the item (image + label) in the collectionview they go to that categorie. So once they click they will get a new collectionview with the items of that categorie (also just an image + label). Now my question is how do I do this? Cause I can't seem to find related study material for my problem. I have been looking all over Google, YouTube and what not. Most of the tutorials or guides I find are for Firebase Realtime Database (so not Firestore) or are just flat out outdated (pre 2017). Also I wonder what the best practices are, do I make a struct for my categories and items? Looking for all round tips here or good reading material so I can learn how to do this. Thanks in advance. This is way too broad a topic for an answer, an...

Make the last row in UITableView appear at top

Make the last row in UITableView appear at top I have a UITableView with a random number of custom cells. It's working fine. I am moving the selected cell to the top of the UITableView with: tableView.scrollTo(index path animated) However, when the selected cell is on the last full 'page' of cells, this doesn't work - obviously. Can I make this work by somehow 'padding' out the table with empty space, dependent on the Y position of the selected cell, so that even selecting the last row, it would animate and move to the top of the table view? I thought: let point = CGPoint(x: 0, y: 200) tableView.setContentOffset(point, animated: false) would work, but it didn't (the 200) was a test amount. I'm sure this is possible, could I please get a pointer? 2 Answers 2 If you want to allow a table view to be scrolled far enough for the last row to reach the top of the screen, set...

iOS 7 TextKit - How to insert images inline with text?

Image
iOS 7 TextKit - How to insert images inline with text? I am trying to get the following effect using a UITextView: Basically I want to insert an image between text. The image can simply just take up 1 row of space so there is no wrapping necessary. I tried just adding a UIView to the subview: UIView *pictureView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 25, 25)]; [pictureView setBackgroundColor:[UIColor redColor]]; [self.textView addSubview:pictureView]; But it seems to float over the text and cover it. I did a bit of reading on exclusion paths which appears to be one way of implementing this. However, I don't want to absolutely position the image - instead, it should flow with the text (similar to how <span> behaves in HTML). <span> A few of the answers mention using the image properties on NSTextAttachment and NSTextField but I want to mention that I need a solution which allows me to append a UIView. – Andy Hin...

Circular image is square on first table refresh

Image
Circular image is square on first table refresh I have a search bar connected to my UITableView . UITableView Here is my code so far: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = SongPicker.dequeueReusableCell(withIdentifier: "cell")! // Image cell.imageView?.image = songHandler.songItems[indexPath.row].songImage?.cropToBounds() cell.imageView?.layer.cornerRadius = cell.imageView!.frame.width / 2 cell.imageView?.layer.masksToBounds = true cell.imageView?.layer.borderWidth = 3 cell.imageView?.layer.borderColor = UIColor.lightGray.cgColor // Song name cell.textLabel?.text = songHandler.songItems[indexPath.row].songName // Artist name cell.detailTextLabel?.text = songHandler.songItems[indexPath.row].songArtist return cell } ( SongPicker is my table) SongPicker By printing out the result of cell.imageView?.layer , I can see that when the images first load, they do no...