Blocking UI Interation whilst image is downloading - iphone

Im using NSThead and have a loading screen whilst im downloading images form the web to display, whist this is happening, could i stop the UI touch being registered? I have buttons on that view and when the loading screen is up, its basicllya text label which has a slightly transparent background. but if someone clicks on it, it registers the back ground buttons being clicked so i want to avoid that.

I recommend to use a UIAlertView for this.
Override the buttons and provide your own "HideIt" handler wich finally call Dismiss...
UIAlterView is somehow a UIView so you can change it's look.
And it blocks the underlying UI without any extra code.
Also possible - Create a (somehow transparent) UIView which covers your View.
You can place a text and / or a UIActivity... on it to show a loading animation.
When loading starts show this thing - when done hide id.
If you want to update this view (Progress indicator / text) be sure to run the updates on the MainThread.
Manfred

Related

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!
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)
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.
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.
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.

Display a box with contents in Iphone View

I am working on an app which displays user information on the home view. Its a regular tab bar application, which brings up the home view on load. I need to display something like,
Hello Joe,
Your current points are : xxx
I would like this to be in a white curved background box. (The background for the view is blue). Is there something like a UIPanel or something like that. I would really like to avoid having another view or a webView, not sure if thats going to affect the speed of loading the page.
If there were a UIPanel control it would derive from UIView, so I'm not sure why you want to avoid another view. If I'm understanding you, it sounds like you want a custom alert window of some sort. You could just use the UIAlertView control to display your message, but if you are dead set on a custom look, then you will need to use a view.
This shouldn't affect performance noticeably if you are just displaying some text with maybe a button on a custom image. Especially if this is just a tab bar application with nothing too crazy happening in the background (animations, etc.).
I would suggest creating a View either in code (this will be slightly faster, but once again probably not noticeably so) or with Interface Builder that has a black background with an opacity of like .2-.5 and on that view adding a UIImageView set to your custom image (a png of a white curved box with transparent corners). Then put a UILabel with your text and a button to dismiss it.
On load just instantiate the above view and add it to your current view. It will show your message modally. Then capture the button tap event to have it remove itself from it's superview.
There are plenty of examples of how to do exactly this out there and there are even other ways of doing it than what I've suggested. If you need further assistance let me know.

iPhone, I need to DB refresh func for a few seconds, how can I show progress before a table screen from tab selection?

I'm developing an app which has a tab bar and a UITableView, sometimes I'll need to run a function to update the database, which takes a few seconds. However, this is only needed if they want to look at a certain screen (and the data need updating) which has a UITableView on it.
I want some advice as to how, what, when and where I should show a progress indicator.
I'm thinking that I'll need something which pops up when the table view is about to be shown ?
As I say I don't know what to use to show the progress?
Also where would it be shown, would I need a new screen which is shown before the the table view or can I use and action sheet which will be dismissed automatically ?
Would like some sample code too.
There are many options for what. You can use a UIActivityIndicator (the spinning circle) or a Progress View (thermometer style) or a UILabel with the text xx% or nothing at all. If you're connecting to the Internet to get data, you should also call [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES] to show the spinning circle in the status bar.
Where is entirely up to you. Apple's own apps have put it into toolbars (c.f. EMail), in the middle of an otherwise blank view (c.f. App Store), or in a single UITableViewCell (c.f., Settings. It shows "Loading applications..." at the bottom when the app first starts while loading Settings.bundle from all installed apps.)
How largely depends on the where and what chosen, but in all cases your DB update needs to be in a background thread so you minimize the effect on the UI. If you're using a Progress View or some numerical feedback you'll want to periodically call something like:
[myViewController performSelectorOnMainThread:#selector(updateProgress:) withObject:[NSNumber numberWithFloat:(1.0 * currentRecord / totalRecords)] waitUntilDone:NO]

UIButton Game character selection to UIImageView animation

I am almost at the end of coding my kids educational application, woohoo!.
But... Im stuck on something.
When app loads i have my main view. It has 4 buttons for flipviews(each with ten views of content) and 4 buttons for character selection(an image that will follow you through every screen of content).
Problem is im unsure on how to link UIButton selection to UIImage display in multiple views. I want the user to choose a character button and then continue to the flipviews and in the views the image displayed should be the one that they have selected on the main view. So everytime they return to the main view they can change the character that will follow them around the app.
Any thoughts, help or code would be much appreciated!
Thank You
Alex
Make a new object, a subclass of UIImageView, which has a -setImage method. Once you set the image, then where ever you embed that object, it will display the same image. You could even have that subclass view have a score displayed next to it, or a name or other stats, so as you go from one screen to another, you have all that info follow you around with the image. No need to create labels in all the screens for global info like that.
In summary:
make a new subclass of UIView or UIImageView in Xcode using the New File... menu. You would do new UIView if you will have other items than just an image.
add methods that allow you to set the image, update text stats etc.
BONUS: you can make the class handle taps, so if a user taps the image, you could do something like provide help or run a cute little animation
embed that object in any screens you wish. Keep in mind that you can have that view be sized differently in each screen using transforms. Cool, no?
that's pretty much it!
Good luck!

How to create a full-screen modal status display on iPhone?

I'm trying to create a modal status indicator display for an iPhone app, and would like one similar to this one used in Tweetie:
Specifically, this one "shades out" the entire screen, including the toolbar. I don't believe through any normal UIView manipulation, I can extend past the bounds of my window, can I? I believe I've seen a status indicator like this somewhere else on iPhone, possibly when I added an Exchange e-mail account.
I've tried subclassing UIAlertView and overriding its drawRect method. If I don't call [super drawRect:] it doesn't ever display the normal UIAlertView text box, however my drawing rectangle is in an odd size and position.
Anyone have any advice to accomplish this?
Check out MBProgressHUD.
Take a look at the source code to the WordPress application. They have code which you can basically drag and drop into your application to do this.
http://iphone.wordpress.org/development/
I haven't done this myself, but you could layer a UIView at the top of the view hierarchy, and use setHidden to dynamically show or hide it. Since it's at the top of the stack, it should be able to intercept all touch events.