Reputation: 2466
I am currently making a registration form for my App. Once the user hits the register button a alert is given to the user to to confirm the number and proceed.
Screenshot of Alert:
If the user hits cancel I perform the following operations:
/*** Reset Mobile Number Input ***/
self.flagMobileNumber = 0
self.validatorIconMobileNumber.setImage(nil, forState: UIControlState.Normal)
self.mobileNumberInput.text = ""
self.mobileNumberInput.becomeFirstResponder()
/*** Disable Register Button ***/
self.registerButton.alpha = 0.5
self.registerButton.userInteractionEnabled = false
But there is a considerable delay that occurs before all the operations are completed.
May someone explain why this happens and what can be done to prevent it.
Upvotes: 0
Views: 51
Reputation: 2897
You are probably aren't on the main thread, doing UI stuff on a different thread (other than the main thread) is discouraged, and usually takes time.
try doing your UI stuff on the main thread:
dispatch_async(dispatch_get_main_queue(), ^{
// do UI stuff here
});
Upvotes: 1