0

Good day ...!

I want to simply hide an UIView (called "secondView") by pressing a button inside it. The problem I'm running into is that when I press the button, it takes a long time (about 20 seconds) to perform the method and hide its superview, and I just see this problem on iphone simulators running on iOS 11.2. I've tested on iOS 9.0 iphone simulator and iphone 5 iOS 10.3 real device. Unfortunately I don't have any real device with iOS 11.2 installed on to test.

this is the method I use to hide the UIView:

-(IBAction)hideSecondView:(id)sender{
    secondView.hidden = YES;
}

According to the topic Showing hidden view really slow and the answer provided by @Duncan C, I changed my code the following:

-(IBAction)hideSecondView:(id)sender{
    dispatch_async(dispatch_get_main_queue(), ^{
        secondView.hidden = YES;
    });
}

But the problem is still there :(

Any help would be appreciated.

Update1:

As the snippet enhanced by @drct, I checked to see if there was any UIKit access on threads other than main. But no catching!

I have a simple test project and the Main thread checker shows that no other tread is spawned by application. I paused execution right along the hiding delay time of secondView.

1 Answers1

0

@Duncan C wrote a nice answer describing your issue.

You may have other code that's trying to do UIKit calls from a background thread when you're not aware of it.

Can you check that you have no other UIKit calls?

  • Thanks for your answer! Considering my level of knowledge I did the check, more explanation is added in update. Is there another check to do? – Morteza J.M. Mar 15 '18 at 07:44