ios – How to make an "Edit" button for a text field in SwiftUI?

I have some text fields that are already complete and I want to add some "Edit" buttons that will show the keyboard I press. Here is the code for one of the text fields:

Image(colorScheme == .light ? "user" : "userDark").resizable().frame(width: 30, height: 30)
                        TextField("Name", text: $name).textFieldStyle(PlainTextFieldStyle()).padding(.leading, 5).font(.system(size: 20))
                        .autocapitalization(.words)
                        .disableAutocorrection(true)
                        if name != localName
                        {
                            Button(action:
                            {
                                self.name = ""
                            })
                            {
                                Text("Update").font(.system(size: 15)).fontWeight(.light)
                                    .foregroundColor(colorScheme == .light ? Color.black : Color.white)
                            }
                        }
                        else if name == localName
                        {
                                Text("Edit").font(.system(size: 15)).fontWeight(.light)
                                    .foregroundColor(colorScheme == .light ? Color.black : Color.white)
                        }

This is what the text fields look like:
enter the image description here

ios – How to avoid the "iPhone is disabled" error when children play with iPhone?

I have a baby who loves to play on my iPhone XS. Naturally, I often tinker with the access code input buttons, and I get the message "iPhone is disabled, please try again in X minutes," which I Googled and Googled and there seems to be no way to disable it. Not only is it annoying, but I'm concerned that at some point you enter the wrong code so many times, that the phone is completely disabled.
I seem to remember that on older iPhones you couldn't get them to require an access code to wake up, but this seems impossible now unless you also want to disable Apple Pay, Face ID to sign in etc. I'm fine with those who require an access code
How can I avoid this dreaded "iPhone is disabled" error? I really don't care about the security it offers, with this lock I am at home all day anyway. 🤷🏽‍♀️

ios – Swift: Cannot simultaneously satisfy constraints

I've been shifting around restrictions and trying to figure this out all day. The app is a simple quiz game, it loads fine, but every time I touch a button it crashes and gives me this error.

Thread 1: signal SIGABRT

Storyboards, viewcontroller and appdelegate here: https://github.com/wrightsteven/quizgame

Any help is really appreciated. Here is what the record says.

2020-03-23 14:31:04.846286-0700 Name That Breed(48289:3644044) (LayoutConstraints) Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "",
    "",
    "",
    ""
)

Will attempt to recover by breaking constraint 


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in  may also be helpful.
2020-03-23 14:31:04.847313-0700 Name That Breed(48289:3644044) (LayoutConstraints) Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "",
    "",
    "",
    ""
)

Will attempt to recover by breaking constraint 


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in  may also be helpful.
2020-03-23 14:31:10.005566-0700 Name That Breed(48289:3644044) -(Name_That_Breed.ViewController NextButtonTapped:): unrecognized selector sent to instance 0x7fdb09e039c0
2020-03-23 14:31:10.012440-0700 Name That Breed(48289:3644044) *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-(Name_That_Breed.ViewController NextButtonTapped:): unrecognized selector sent to instance 0x7fdb09e039c0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23baa1ee __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff50864b20 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23bcb154 -(NSObject(NSObject) doesNotRecognizeSelector:) + 132
    3   UIKitCore                           0x00007fff475a6e79 -(UIResponder doesNotRecognizeSelector:) + 302
    4   CoreFoundation                      0x00007fff23baef6c ___forwarding___ + 1436
    5   CoreFoundation                      0x00007fff23bb10f8 _CF_forwarding_prep_0 + 120
    6   UIKitCore                           0x00007fff4757a082 -(UIApplication sendAction:to:from:forEvent:) + 83
    7   UIKitCore                           0x00007fff46f608e5 -(UIControl sendAction:to:forEvent:) + 223
    8   UIKitCore                           0x00007fff46f60c2f -(UIControl _sendActionsForEvents:withEvent:) + 398
    9   UIKitCore                           0x00007fff46f5fb8e -(UIControl touchesEnded:withEvent:) + 481
    10  UIKitCore                           0x00007fff475b4a31 -(UIWindow _sendTouchesForEvent:) + 2604
    11  UIKitCore                           0x00007fff475b6338 -(UIWindow sendEvent:) + 4596
    12  UIKitCore                           0x00007fff47591693 -(UIApplication sendEvent:) + 356
    13  UIKitCore                           0x00007fff47611e5a __dispatchPreprocessedEventFromEventQueue + 6847
    14  UIKitCore                           0x00007fff47614920 __handleEventQueueInternal + 5980
    15  CoreFoundation                      0x00007fff23b0d271 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    16  CoreFoundation                      0x00007fff23b0d19c __CFRunLoopDoSource0 + 76
    17  CoreFoundation                      0x00007fff23b0c974 __CFRunLoopDoSources0 + 180
    18  CoreFoundation                      0x00007fff23b0767f __CFRunLoopRun + 1263
    19  CoreFoundation                      0x00007fff23b06e66 CFRunLoopRunSpecific + 438
    20  GraphicsServices                    0x00007fff38346bb0 GSEventRunModal + 65
    21  UIKitCore                           0x00007fff47578dd0 UIApplicationMain + 1621
    22  Name That Breed                     0x000000010b513b4b main + 75
    23  libdyld.dylib                       0x00007fff516ecd29 start + 1
    24  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

dart: fluttering iOS location of controller_handler

I am trying to know if the user selected when it is in use or always (location permissions).

I use this code in an IOS 13 simulator

static Future checkPermissions() async {
    PermissionStatus permission = await PermissionHandler()
        .checkPermissionStatus(PermissionGroup.locationAlways);
    return permission;
  }

This returns "GRANTED", I would like it to return "always" or "when_used".

it's possible?

Thanks in advance!

IOS 13.x brings the iPhone to life if the disk is full

So as you can guess this is the most obvious question: how can I free up disk space on the device to get it to communicate again?

Second question: How can this really happen? Apple added a journal file system that works if the journal is getting too big?

HIGH VALUE: iOS app UI / UX designer required

I have run many high value contests In the forum for the design of logos and posters in the past, you can see them on my profile.

I have a iOS application design project now where am i hire a UI / UX designer. It is an application for the US market. USA Aimed at university students, with a total of 30 screens.

Send me a message with your portfolio and we can talk about pricing and other details.

Thank you!
K

ios: pass a URL from a table view controller to a view controller with AVAudioPlayer

I am currently trying to play audio from my Firebase database. I have two view controllers, the first is a table view controller and the second is a view controller with AVAudioPlayer. I am trying to figure out how to successfully play the audio url that is taken from the firebase which is then passed to the second view controller to play when the audio is selected in table view. Here is my current code that returns "Fatal error: null found unexpectedly when unwrapping an optional value" in my second view controller when audio is selected from the table view controller.

TableViewController:

import UIKit
import Firebase

class HeaderViewTableViewController: UITableViewController {


    @IBOutlet weak var trackImage: UIImageView!
    @IBOutlet weak var trackName: UILabel!
    @IBOutlet weak var artistName: UILabel!
    @IBOutlet weak var trackHeaderImage: UIImageView!

    var image: UIImageView?
    var image2: UIImageView?

    var songs = (String)()
    var urls = (URL)()

    var song:SongPost?

    private let tableHeaderViewHeight: CGFloat = 350.0
    private let tableHeaderViewCutAway: CGFloat = 0.1

    var headerView: HeaderView!
    var headerMaskLayer: CAShapeLayer!

    override func viewDidLoad() {
        super.viewDidLoad()



        print(song)

        trackName.text = song?.title

        ImageService.getImage(withURL: song!.coverImage) { image in
         self.trackImage.image = image
            self.trackHeaderImage.image = image
        }
        artistName.text = song?.author.fullname




        tableView.tableFooterView = UIView()

        headerView = tableView.tableHeaderView as! HeaderView
        headerView.imageView = trackImage
        tableView.tableHeaderView = nil
        tableView.addSubview(headerView)

        tableView.contentInset = UIEdgeInsets(top: tableHeaderViewHeight, left: 0, bottom: 0, right: 0)
        tableView.contentOffset = CGPoint(x: 0, y: -tableHeaderViewHeight + 64)

        //cut away header view
        headerMaskLayer = CAShapeLayer()
        headerMaskLayer.fillColor = UIColor.black.cgColor
        headerView.layer.mask = headerMaskLayer

        let effectiveHeight = tableHeaderViewHeight - tableHeaderViewCutAway/2
        tableView.contentInset = UIEdgeInsets(top: effectiveHeight, left: 0, bottom: 0, right: 0)
        tableView.contentOffset = CGPoint(x: 0, y: -effectiveHeight)

        updateHeaderView()
    }

    func updateHeaderView() {
        let effectiveHeight = tableHeaderViewHeight - tableHeaderViewCutAway/2
        var headerRect = CGRect(x: 0, y: -effectiveHeight, width: tableView.bounds.width, height: tableHeaderViewHeight)

        if tableView.contentOffset.y < -effectiveHeight {
            headerRect.origin.y = tableView.contentOffset.y
            headerRect.size.height = -tableView.contentOffset.y + tableHeaderViewCutAway/2
        }

        headerView.frame = headerRect

        let path = UIBezierPath()
        path.move(to: CGPoint(x: 0, y:0))
        path.addLine(to: CGPoint(x: headerRect.width, y: 0))
        path.addLine(to: CGPoint(x: headerRect.width, y: headerRect.height))
        path.addLine(to: CGPoint(x: 0, y: headerRect.height - tableHeaderViewCutAway))

        headerMaskLayer?.path = path.cgPath
    }


      override func touchesMoved(_ touches: Set, with event: UIEvent?) {
          self.tableView.decelerationRate = UIScrollView.DecelerationRate.fast
      }

      override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
          return UITableView.automaticDimension
      }



    @IBAction func backButton(_ sender: Any) {
        dismiss(animated: true, completion: nil)
    }

}

extension HeaderViewTableViewController {


    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return (song?.audioName.count)!
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "SongCell", for: indexPath) as! SongNameTableViewCell

        cell.set(song: self.song!)

        cell.songName.text = song?.audioName(indexPath.row)
        return cell
    }

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        let vc = storyboard?.instantiateViewController(identifier: "ViewController2") as? ViewController2
        vc?.song = song
        vc?.audioName = (song?.audioName(indexPath.row))!

        self.present(vc!, animated: true, completion: nil)
        vc?.url = song?.audioUrl(indexPath.row)

    }

}


extension HeaderViewTableViewController {
    override func scrollViewDidScroll(_ scrollView: UIScrollView) {
        updateHeaderView()
    }
}

Second ViewController:

import UIKit
import AVFoundation
import MediaPlayer
import Firebase

class ViewController2: UIViewController, UITabBarControllerDelegate {



    var song2 = (SongPost)()

    var song: SongPost?
    var audioName : String?
    var url:URL?

    @IBOutlet weak var progressBar: UISlider!
    @IBOutlet weak var downChevron: UIButton!
    var timer:Timer?
    var player = AVAudioPlayer()

    @IBOutlet weak var currentTime: UILabel!
    @IBOutlet weak var durationTime: UILabel!

    @IBOutlet weak var coverImage: UIImageView!
    @IBOutlet weak var backgroundImage: UIImageView!
    @IBOutlet weak var songName: UILabel!
    @IBOutlet weak var artistName: UILabel!
    var trackID: Int = 0
    var toggleState = 1

    var ref: DatabaseReference?


    @IBOutlet weak var playButton: UIButton!


    override func viewDidLoad() {
        super.viewDidLoad()

        setUI()


        tabBarController?.tabBar.barTintColor = UIColor.black
        tabBarController?.tabBar.isTranslucent = false

        tabBarController?.tabBar.tintColor = .white
        tabBarController?.tabBar.unselectedItemTintColor = .gray


        do {

            let songURL = url

            print(songURL)
            try player = AVAudioPlayer(contentsOf: songURL!)
            progressBar.maximumValue = Float(player.duration)
            timer = Timer.scheduledTimer(timeInterval: 0.00001, target: self, selector: #selector(changeSliderValueFollowPlayerCurtime), userInfo: nil, repeats: true)
            player.delegate = self

            player.play()


            MPNowPlayingInfoCenter.default().nowPlayingInfo = (
                MPMediaItemPropertyTitle : "The Box",
                MPMediaItemPropertyArtist: "Roddy Ricch",
                MPMediaItemPropertyPlaybackDuration: player.duration,

            )
            UIApplication.shared.beginReceivingRemoteControlEvents()
            becomeFirstResponder()


        } catch {


        }

        do {
             try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, options: .defaultToSpeaker)
        } catch {

        }

    }


    func setUI() {

        ImageService.getImage(withURL: song!.coverImage) { image in
                       self.coverImage.image = image
                          self.backgroundImage.image = image
                      }
               songName.text = song?.title
               artistName.text = song?.author.fullname
    }


    override func remoteControlReceived(with event: UIEvent?) {
        if let event = event {
            if event.type == .remoteControl {
                switch event.subtype {
                case .remoteControlPlay:
                    player.play()
                case .remoteControlPause:
                    player.pause()
                case .remoteControlNextTrack:
                    print("next")
                case .remoteControlPreviousTrack:
                    print("previous")
                default:
                    print("error")
                }
            }
        }
    }

    @objc func changeSliderValueFollowPlayerCurtime() {

        let curValue = Float(player.currentTime)
        progressBar.value = curValue

    }


    @IBAction func sliderUsed(_ sender: Any) {
        player.pause()
        let curTime = progressBar.value
        player.currentTime = TimeInterval(curTime)
        player.play()
    }

    @IBAction func playPauseButtonTapped(_ sender: Any) {
        let playBtn = sender as! UIButton
               if toggleState == 1 {
                  player.pause()
                toggleState = 2
                playBtn.setImage(UIImage(named:"play 5.png"),for:UIControl.State.normal)

               } else {
                player.play()
                   toggleState = 1
                playBtn.setImage(UIImage(named:"pause 4.png"),for:UIControl.State.normal)

               }
    }


    @IBAction func nextButton(_ sender: Any) {


    }

    @IBAction func backButton(_ sender: Any) {
        if trackID != 0 || trackID > 0 {

            trackID -= 1
        }

        do {
            let audioPath = Bundle.main.path(forResource: "the box", ofType: "mp3")
            try player = AVAudioPlayer(contentsOf: NSURL(fileURLWithPath: audioPath!) as URL)
        } catch {


        }


    }

    @IBAction func downChevronTapped(_ sender: Any) {

        dismiss(animated: true, completion: nil)
    }

}

extension ViewController2: AVAudioPlayerDelegate {
    func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) {
        if flag {
            do {

                    let audioPath = Bundle.main.path(forResource: "the box", ofType: "mp3")
                try self.player = AVAudioPlayer(contentsOf: NSURL(fileURLWithPath: audioPath!) as URL)

                    progressBar.maximumValue = Float(player.duration)
                    timer = Timer.scheduledTimer(timeInterval: 0.00001, target: self, selector: #selector(changeSliderValueFollowPlayerCurtime), userInfo: nil, repeats: true)
                    player.delegate = self

                    player.play()
                } catch {

                }
        }
    }
}

SongPost class:

import Foundation

class SongPost {
    var id: String
    var author: UserProfile
    var title: String
    var coverImage: URL
    var audioUrl: (URL)
    var audioName : (String)
    var createdAt:Date



    init(id:String, author:UserProfile, title:String, coverImage:URL, audioUrl:(URL), audioName: (String) ,timestamp:Double) {
        self.id = id
        self.author = author
        self.coverImage = coverImage
        self.audioUrl = audioUrl
        self.audioName = audioName

        self.title = title
        self.createdAt = Date(timeIntervalSince1970: timestamp / 1000)
    }

}

ios – Firebase Facebook to Google authentication link

After much testing, I decided to create a new xCode project to better understand Firebase authentication with multiple providers.

I set up in Firebase -> Login methods -> One account per email address

An email account

Prevent users from creating multiple
accounts that use the same email address with different authentication
providers

At this point I have implemented, carefully following the Firebase guide, login with Facebook and with Google .. Everything seems to work perfectly but I always run into the same error that I can't handle:

When my user creates a Firebase account through Google you can no longer login if you decide to use Facebook.

Facebook it returns its error when it completes its authentication flow with Firebase:

Firebase Error With Facebook Provider: An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.

Continuing with the step-by-step documentation, I stopped here (firebase explains how to handle this error)

I have also implemented error handling but after calling Auth.auth().fetchSignInMethods Firebase says it should authenticate user with existing provider, at this point how do I get credentials for authentication with existing provider?


  • I would not like to reopen the existing provider driver to get new credentials

  • Am I required to ask the user to log in with the existing provider and show another access controller again (in this case the one for Google)?

  • How should I handle this situation?

    StartController class: UIViewController, LoginButtonDelegate {

    override function viewDidLoad () {
    super.viewDidLoad ()

    let loginButton = FBLoginButton (permissions: (.publicProfile, .email))
    loginButton.center = view.center
    loginButton.delegate = self
    view.addSubview (loginButton)
    }

// MARK: – Facebook delegate

func loginButton (_ loginButton: FBLoginButton, didCompleteWith result: LoginManagerLoginResult?, error: Error?) {

if let error = error {
    print(error.localizedDescription)
    return
}

let credential = FacebookAuthProvider.credential(withAccessToken: AccessToken.current!.tokenString)
Auth.auth().signIn(with: credential) { (authResult, error) in

    if let error = error {
        print("n FIREBASE: ",error.localizedDescription)

        // An account with the same email already exists.
        if (error as NSError?)?.code == AuthErrorCode.accountExistsWithDifferentCredential.rawValue {
            // Get pending credential and email of existing account.
            let existingAcctEmail = (error as NSError).userInfo(AuthErrorUserInfoEmailKey) as! String
            let pendingCred = (error as NSError).userInfo(AuthErrorUserInfoUpdatedCredentialKey) as! AuthCredential
            // Lookup existing account identifier by the email.
            Auth.auth().fetchSignInMethods(forEmail: existingAcctEmail) { providers, error in

                 if (providers?.contains(GoogleAuthProviderID))! {

                    // Sign in with existing account.
                    Auth.auth().signIn(with: "? ? ? ?") { user, error in
                      // Successfully signed in.
                      if user != nil {
                        // Link pending credential to account.
                        Auth.auth().currentUser?.link(with: pendingCred) { result, error in

                             // Link Facebook to Google Account

                        }

                        }
                }
            }
        }
    }
}

}

ios: iPhone application that detects touching the face

I would like to detect touching the face to avoid virus infection. I have found Immutouch, an Instructable with a tilt switch, an app for fitbit, and websites that use the webcam to detect face contact (I don't know if they are legitimate or a window front for crypto-jacking, so no Do not include them here).

If an app is available for existing hardware, you could start using it immediately when you're away from the computer. An online search for iphone app detect face-touching primarily returns the results of face detection and face recognition.

Could I detect touching the face with an app and the iPhone tied to my wrist?

I update the latest version of ios app but don't update notification on device

I have an app in the app store. Last week I made an updated version for review in the app store.

But there is no notification that the new version of the application is available in the store.

Please lend me a hand with this.