Nuzhat Zari
Nuzhat Zari

Reputation: 3408

Loading screen is not working properly

In my app I am showing loading screen when request is sent to server and when response is received I am removing that loading screen.

To display loading screen I used UIView and reduce its alpha to 0.5 so that it shows the background view.

My problem is user is able to click button displayed on background view when loading screen is still visible.

What I want is: User should not be able to click anywhere on the screen when loading screen is visible. Even though I made userInteractionEnabled false for UIView but still user is able to click on button, why?

If any one knows where I am doing wrong and how I can achieve this, please let me know.

Thanks in advance!

Upvotes: 0

Views: 125

Answers (4)

Meenakshi
Meenakshi

Reputation: 1162

You can use [[UIApplication sharedApplication] beginIgnoringInteractionEvents] when you are sending request to server & shows loading view.When you receives the response call [[UIApplication sharedApplication] endIgnoringInteractionEvents] & remove the loading view.

Upvotes: 0

Nuzhat Zari
Nuzhat Zari

Reputation: 3408

Yes I got it, I did userInteractionEnabled false for UIView so the click event was sent to the button which was on main view.I removed userInteractionEnabled false and it is working fine.

Upvotes: 0

Nimit Parekh
Nimit Parekh

Reputation: 16864

Like wise the utility open source library available.

iOS open source project is MBProgressHUD,

it refers to Heads Up Display, a view that is overlayed on another view, typically to show an activity indicator and/or offer a means to interact with the UI. A good example of an HUD is when playing a movie with the built in movie player. When you tap the screen, the movie player will show a series of controls on the display. Another common example, and one that is pertinent to MBProgressHUD, is showing progress indicators on top of an existing view. For example, when accessing a remote service, to provide feedback to the user you may opt to display a “Please Wait” message

you can download the source code from here.

Upvotes: 0

Elmo
Elmo

Reputation: 407

The UIView may have interaction disabled but if the button is higher on the view hierarchy then its on TOP of the view so it's still accessible.

If this is a view made in the nib then make sure its at the top of the view stack

Or if its programmatically then add it as a subview at the end of the function or add it mainWindow (be VERY careful adding things to main Window, this is the top of the hierarchy)

Upvotes: 1

Related Questions