I want to display dynamic UIAlertView and Indicator within it when data is loading from web-service.
Also I don't want any button on UIAlertView. And it will be stopped automatically when data will be loaded successfully.
How can I implement it.?
Just declar UIAlertView and then your activity indicator, make indicator a sub view to alert view and then when your data has been loaded from web service dismiss with this instance method
– dismissWithClickedButtonIndex:animated:
If you are using WebView then write startAnimating ActivityIndicator in ViewDidLoad and this delegate method will call by itself when your data will be loaded
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[ActivityIndicator stopAnimating];
}
Hope it helps.Thanks :)
Then use MBProgress HUD or SVprogress HUD
https://github.com/jdg/MBProgressHUD
Related
I my application i want to hide the UIPickerview controller when application enter's in a paused state?
for eg: in my viewcontroller i am using uipickerview,and is placed in a popovercontroller,but i have not dismiss the popovercontroller and the application goes in a paused state.
when user open the application the uipikcer view is displayed which i want to dismiss.
please help me out with this.
Use NSNotificationCenter for hide the UIPickerView when application go in background like bellow...
[[NSNotificationCenter defaultCenter] addObserver:alertView selector:#selector(HidePickerView) name:#"UIApplicationWillResignActiveNotification" object:nil];
and hide the UIPickerView in bellow method..
- (void) HidePickerView {
[yourPickerView setHidden:YES];
}
You need to subscribe for the UIApplicationWillResignActiveNotification notification and when it's fired and your selector is called, you should [self.myPickerView dismissViewControllerAnimated:NO completion:nil];.
Note: -viewWillDisappear: method would not be called when the app is resigning active.
I would like it to stop spinning once the website finishes loading...
The code I have it:
in my .h
IBOutlet UIActivityIndicatorView *activityIndicator;
in my .m
- (void)webViewDidStartLoad:(UIWebView *)webView {
[activityIndicator startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[activityIndicator stopAnimating];
self.view = webView;
}
I then hooked it up to files owner in the nib. It spins, but doesn't stop! Any suggestions? Thanks!
Does the web view ever actually finish loading? Set a breakpoint and see if you ever even hit that method.
And, for completeness...you do have the delegate of the webview set to your view controller, correct (I assume you do, as it starts animating, but you never know)?
There are two ways you can set the delegate of the webview. If you have it in your nib, control click on the webview and drag from the delegate property to File's Owner. Or, in viewDidLoad, just say _webView.delegate = self;
UPDATE: After our conversation, and in regards to the comments below, I just want to add this for completeness, and for anyone else who sees this in the future with the same issue. The reason your webView was getting huge after it finished loading was because you were assigning it to the view property of your view controller when you said self.view = webview. No need for that. Take that out, and you'll be fine.
Make sure you have the correct toggle settings on the actual UIActivityIndicatorView object in Interface Builder and make sure it's linked correctly. I believe you want "hides when stopped".
Also make sure you have the WebView Delegate implemented.
should work the way you implemented it.
Add following code
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[loadIndicator stopAnimating];
}
Maybe your UIWebView doesn't finish loading properly.
I have an implanted Facebook in my app. When it is posting something on Facebook it is displaying a Activity Indicator wich works as it should but I want to show a checkmark when it is finished with posting. I am not sure how to do this. This is the code when it is finished with loading
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
//Stop the spinner
[ActivityView removeView];
}
Look at - https://github.com/jdg/MBProgressHUD
It is very easy to use and has many examples.
If you're using a XIB, place the checkmark in an imageView and then position it where you want in your view. Wire it to an IBOutlet so you can access it from your view controller. Set the imageView's property to be hidden initially.
In your didReceiveResponseMethod, update the imageView's property to:
imageView.hidden = NO;
In my iphone app I have a table view. In that onclick of each row it will download some data. During that download process I need to animate an activity indicator. How to add an activity indicator in table view?
First, you do not need to add activity indicator in table view. You just add it in that view and then set its hidden property. When the user clicks on a row, set its hidden property to NO.
One more thing, move your table to send to back from layout->send to back
and the indicator to send to front layout->sent to front.
Just add an UIActivityIndicatorView to your view say activity Assign it the frame and style you want.
Then all you need to do is that put the below code above your download code.
[NSThread detachNewThreadSelector:#selector(myMethod:) toTarget:self withObject:nil];
and you need to declare myMethod as
-(void)myMethod:(id)data
{
[activity startAnimating];
[activity setHidden:NO];
}
Whenever your download finishes just put
[activity stopAnimating];
[activity setHidden:YES];
Hope this helps you.
I am trying to add some titles to my project. So, when my app gets loaded it should show my title screen with activity indicator spinning and after 3seconds it should push the navigation controller. Basically I will have an image on the first view controller. So, in IB I added an image view and set the image. Please help me guys how to load second view controller after the first view controller gets loaded..
Basically please tell me how to push navigation controller after particular time delay without any buttons or any other controls in it..
Thanks for all your time..
EDIT
- (void)viewDidLoad {
[super viewDidLoad];
[indicator startAnimating];
timer=[NSTimer scheduledTimerWithTimeInterval: 3.0 target:self selector:#selector(loadNextView) userInfo:nil repeats: YES];
}
-(void)loadNextView
{
TabBarControllers *tabBar=[[TabBarControllers alloc]initWithNibName:#"TabBarControllers" bundle:nil];
[self.navigationController pushViewController:tabBar animated:YES];
[indicator stopAnimating];
}
There's also lots of iPhone example code that uses an NSTimer to call any method on any object after a specified delay. Just create a method to stop the activity indicator and push your next controller, and call that method via a 3 second NSTimer after starting the activity indicator in your first view.
Take a look at the NSObject's performSelector:withObject:afterDelay: method. You should able to specify 3 seconds delay to perform the action.