Posts

Post not yet marked as solved
1 Replies
4.6k Views
I have been doing some tests with the code to DownSampling / Scaling Image an Image from WWDC18 Session 416 iOS Memory Deep Dive.In this session they said that: - "Memory use if related the DIMENSION of the image, NOT file size.” - UIImage is expensive for sizing and resizing (will decompress memory first, internal coordinate space transforms are expensive) - Use ImageIO, it will work with out dirty memory (also API is faster)For my tests I used High Resolution Images with dimensions:1920 × 1080, 2560 × 1600, 3840 × 2160, 2560 × 1600, 4712 × 3133, 2560 × 1600 and 3072 × 2048.The following is the code that I used.import UIKit struct ImageConverter{ static func resize(image: UIImage)-> UIImage{ let size = CGSize(width: 300, height: 300) let renderer = UIGraphicsImageRenderer(size: size) let resizedImage = renderer.image { context in image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height)) } return resizedImage } }import UIKit import ImageIO struct ImageIOConverter{ static func resize(url: URL)-> UIImage{ guard let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) else { fatalError("Can not get imageSource") } let options: [NSString: Any] = [ kCGImageSourceThumbnailMaxPixelSize: 300, kCGImageSourceCreateThumbnailFromImageAlways: true ] guard let scaledImage = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options as CFDictionary) else { fatalError("Can not get scaledImage") } return UIImage(cgImage: scaledImage) } }import UIKit class ViewController: UIViewController { @IBOutlet weak var imageView: UIImageView! // Constraints Width: 300, Height: 300 let resource = "1" let ext = ".jpg" var imageNamed : String { return resource + ext } @IBAction func uploadOriginalImage(_ sender: Any) { guard let image = UIImage(named: imageNamed) else { fatalError("Can not get image") } imageView.image = image } @IBAction func uploadImageScaledUsingUIImage(_ sender: Any) { guard let image = UIImage(named: imageNamed) else { fatalError("Can not get image") } imageView.image = ImageConverter.resize(image: image) } @IBAction func uploadImageUsingImageIO(_ sender: Any) { guard let url = Bundle.main.url(forResource:resource, withExtension: ext) else { fatalError("Can not get image url") } imageView.image = ImageIOConverter.resize(url: url) } }Effectively, I found that with ImageIO, the amount of memory is smaller, but at the same time I also noticed that using ImageIO the final image look to have lower quality than using UIImage.I mean, using UIImage the final image looks more to the original image than using ImageIO.I wonder if, Is this the expected result? (Lower image quality but also lower memory).
Posted
by ManuelMB.
Last updated
.
Post not yet marked as solved
0 Replies
1k Views
I have a simple ViewController with a WKWebView, the page renders ok and there is no problem at first. This is the code: import WebKit class SignIWkWebViewViewController: UIViewController {      var wkWebView: WKWebView!    override func loadView() {      let webConfiguration = WKWebViewConfiguration()      wkWebView = WKWebView(frame: .zero, configuration: webConfiguration)      view = wkWebView    }      override func viewDidLoad() {      super.viewDidLoad()      startLoad()    }        // Receive Transfer Details and Results with a Delegate    private lazy var session: URLSession = {      let configuration = URLSessionConfiguration.default      configuration.waitsForConnectivity = true      return URLSession(configuration: configuration, delegate: self, delegateQueue: nil)    }()        var receivedData: Data?        private func startLoad(){      print("\(type(of: self)) \(#function)")            guard let url = URL(string:"https://itunesconnect.apple.com/login") else { fatalError("Can not get url") }            receivedData = Data()      let task = session.dataTask(with: url)      task.resume()    }        private func handleClientError(_ error: Error){      print("Error: \(error)")    } }     extension SignIWkWebViewViewController : URLSessionDataDelegate{  func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {     print("\(type(of: self)) \(#function)")      guard let response = response as? HTTPURLResponse,        (200...299).contains(response.statusCode),        let mimeType = response.mimeType,        mimeType == "text/html" else {        completionHandler(.cancel)        return      }      completionHandler(.allow)    }    func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {      print("\(type(of: self)) \(#function)")      self.receivedData?.append(data)    }    func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {       print("\(type(of: self)) \(#function)")      DispatchQueue.main.async {        //self.loadButton.isEnabled = true        if let error = error {          self.handleClientError(error)        } else if let receivedData = self.receivedData,          let string = String(data: receivedData, encoding: .utf8) {          self.wkWebView.loadHTMLString(string, baseURL: task.currentRequest?.url)        }      }    } } The issue start when I tap in the form field in the web page. I set a breakpoint for UIViewAlertForUnsatisfiableConstraints expr -l objc++ -O -- [[UIWindow keyWindow] autolayoutTrace] And I got this error: UIWindow:0x7f9ed2d05d40 |  UITransitionView:0x7f9ed2c110f0 |  |  UIDropShadowView:0x7f9ed2e071c0 |  |  |  WKWebView:0x7f9ed3027e00'iTunes Connect' |  |  |  |  WKScrollView:0x7f9ed3827800 |  |  |  |  |  WKContentView:0x7f9ed382f800 |  |  |  |  |  |  UIView:0x7f9ed2c0a240 |  |  |  |  |  |  |  UIView:0x7f9ed2c067a0 |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2d13760 |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed501d6c0 |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed500cfd0 |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed50063c0 |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed501d830 |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c18210 |  |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c107a0 |  |  |  |  |  |  |  |  |  |  |  |  |  |  WKChildScrollView:0x7f9ed3081200 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c14a30 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c19810 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c10910 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c17dc0 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c19560 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  UIScrollViewScrollIndicator:0x7f9ed500f3f0 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  UIView:0x7f9ed500f590 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  UIScrollViewScrollIndicator:0x7f9ed5019150 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  UIView:0x7f9ed50177d0 |  |  |  |  |  |  |  |  |  |  |  |  WKCompositingView:0x7f9ed2c0fd20 |  |  |  |  |  |  UILayerHostView:0x7f9ed2d09100 |  |  |  |  |  UIView:0x7f9ed5007fd0 |  |  |  |  |  |  UITextSelectionView:0x7f9ed501bbd0 |  |  |  |  |  |  UIHighlightView:0x7f9ed2e0b7f0 |  |  |  |  |  UIScrollViewScrollIndicator:0x7f9ed2e0ad40 |  |  |  |  |  |  UIView:0x7f9ed2e0b680 |  |  |  |  |  _UIScrollViewScrollIndicator:0x7f9ed2e0bb30 |  |  |  |  |  |  UIView:0x7f9ed2e0bcd0 Legend:- is laid out with auto layout + - is laid out manually, but is represented in the layout engine because translatesAutoresizingMaskIntoConstraints = YES • - layout engine host What is wrong in the code?
Posted
by ManuelMB.
Last updated
.
Post not yet marked as solved
1 Replies
651 Views
In https://appstoreconnect.apple.com I found the following message: The updated Apple Developer Program License Agreement needs to be reviewed The updated Apple Developer Program License Agreement needs to be reviewed. In order to update your existing apps and submit new apps to the App Store, the Account Holder must review and accept the updated agreement by signing in to their account on the Apple Developer website. I went to: https://developer.apple.com/account But I can not find the updated Apple Developer Program License Agreement needs to be reviewed. In: https://developer.apple.com/account/#/membership/XXXXXXXXX (XXXXXXXXX) is my account ID at the bottom I can see Agreements (2), but If I click in any of then it just download a pdf file. Where I need to go to accept it?
Posted
by ManuelMB.
Last updated
.
Post not yet marked as solved
2 Replies
4.1k Views
Hello,I have a big problem, when I try to go to settings in the simulators, the screen goes sometimes to white and sometimes to black, but returns to the Home Screen, sometimes even it restart my Mac.I tried to uninstall all simulators, install again Xcode, but the issue is not solve.I also tried Reset NVRAM or PRAM on Mac.Before to ask here in the forum, I tried to go to Support > Contact us > Development and technical issues > Xcodehttps://developer.apple.com/contact/#!/topic/SC1102/subtopic/30019/solution/selectBut there is no option there to submit the selection and no way to continue further, I tried in 3 different web browsers.Please help me, I have wasted 3 days trying to solve this problem.
Posted
by ManuelMB.
Last updated
.
Post marked as solved
2 Replies
647 Views
I am having issues with renewing subscriptions.From Session 705 Engineering Subscriptions WWDC 2018 - Does the User Have an Active Subscription?, I know that the way to answer to these questions is: - Filter transactions by original_transaction_id - Find transaction with the latest expires_date - Date in past shows user is not subscribed Subscription Period ---------------------------------------------------------> Time ---> USER HAS NO AN Active Subscription expires_date Today Subscription Period ---------------------------------------------------------> Time ---> USER HAS AN Active Subscription Today expires_date But I get the following data: 6 elements ▿ 0 : InApp ▿ expiresDate : 2020-05-02 21:31:29 +0000 ▿ 1 : InApp ▿ expiresDate : 2020-05-02 21:36:29 +0000 ▿ 2 : InApp ▿ expiresDate : 2020-05-02 21:41:29 +0000 ▿ 3 : InApp ▿ expiresDate : 2020-05-02 21:46:29 +0000 ▿ 4 : InApp ▿ expiresDate : 2020-05-02 21:51:51 +0000 ▿ 5 : InApp ▿ expiresDate : 2020-05-02 21:56:51 +0000 <====== transaction with the latest expires_datelet today = Date()2020-05-03 21:48:29 +0000Transaction with the latest expires_date is before Today.Why is this happening?
Posted
by ManuelMB.
Last updated
.
Post not yet marked as solved
0 Replies
3.0k Views
In WWDC 2019 session In-App Purchases and Using Server-to-Server Notifications they say that in our server we must have in a database a field for the userId.I think that a good candidate to use as userId for iOS and tvOS would be identifierForVendor:UIDevice.current.identifierForVendor?.uuidStringAnd for macOS the GUID but the info that I found in the Apple documentation uses Objective-C instead of Swift:https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html#//apple_ref/doc/uid/TP40010573-CH1-SW14Is there info about who to do it using Swift somewhere or should I use Objective-C?I also found some code of Swift in github, but I do not now if really get the real Mac UUID and also if this method is allowed by Apple. func macSerialNumber() -> String { let platformExpert: io_service_t = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); guard let serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformSerialNumberKey as CFString, kCFAllocatorDefault, 0) else { fatalError("Can not get serialNumberAsCFString") } IOObjectRelease(platformExpert); return (serialNumberAsCFString.takeUnretainedValue() as? String) ?? "" } func applicationDidFinishLaunching(_ aNotification: Notification) { print("Unique Device Identifier: \(macSerialNumber())") }
Posted
by ManuelMB.
Last updated
.
Post marked as solved
1 Replies
1k Views
In a UIViewcontroller I set:navigationController?.navigationBar.barTintColor = .blackI would like to change the default appearance of the following:Carrier name and its signal strength, wifi strength or (3G, 4G or 5G), clock time, battery level and network activity indicator when is visible.Because with a black navigationBar barTintColor these are indistinguishable.How could I do it?
Posted
by ManuelMB.
Last updated
.