Third-party Wait indicator. MBProgressHUD is a third-party Wait indicator framework. Below are the wait indicator styles provided by MBProgressHUD. They can be divided into two categories: Unknown End Time and known end time. In MBProgressHUD, you can add labels and detailed labels for the wait indicator.
650) this. width = 650; "width =" 455 "height =" 615 "src =" http://www.bkjia.com/uploads/allimg/131228/0F2424339-0.jpg "alt =" 9 "class =" aligncenter size-full wp-image-67 "/> 650) this. width = 650; "width =" 456 "height =" 303 "src =" http://www.bkjia.com/uploads/allimg/131228/0F2425c4-1.jpg "alt =" 10 "class =" aligncenter size-full wp-image-68 "/>
MBProgressHUD is https://github.com/matej/mbprogresshud. we will download the MBProgressHUD from the source file. h and MBProgressHUD. m is copied to your project. The frameworks on which MBProgressHUD depends are: Foundation. framework, UIKit. framework and CoreGraphics. framework, we need to add these frameworks to the project.
Add the MBProgressHUD wait indicator to the application, and modify the startRequest method code of MasterViewController. m in the master View Controller as follows. Note the bold Section:
- -(Void) startRequest
-
- {
-
- // Initialize MBProgressHUD
-
- MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo: self. view animated: YES];
-
- Hud. mode = MBProgressHUDModeCustomView;
-
- Hud. labelText = @ "Loading ";
-
- NSString * strURL = [[NSString alloc]
-
- InitWithFormat: @ "http: // iosbook3/mynotes/webservice. php"];
-
- NSURL * url = [NSURL URLWithString: [strURL URLEncodedString];
-
- NSString * post;
-
- If (action = ACTION_QUERY) {// query processing
-
- Post = [NSString stringWithFormat: @ "email =%@ & type =%@ & action =% @",
-
- @ "<Your iosbook1.com user email>", @ "JSON", @ "query"];
-
- } Else if (action = ACTION_REMOVE) {// Delete
-
- NSIndexPath * indexPath = [self. tableView indexPathForSelectedRow];
-
- NSMutableDictionary * dict = self. listData [indexPath. row];
-
- Post = [NSString stringWithFormat: @ "email =%@ & type =%@ & action =%@ & id =% @",
-
- @ "<Your iosbook1.com user email>", @ "JSON", @ "remove", [dict objectForKey: @ "ID"];
-
- }
-
- NSData * postData = [post dataUsingEncoding: NSUTF8StringEncoding];
-
- NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL: url];
-
- [Request setHTTPMethod: @ "POST"];
-
- [Request setHTTPBody: postData];
-
- NSURLConnection * connection = [NSURLConnection alloc]
-
- InitWithRequest: request delegate: self];
-
- If (connection ){
-
- _ Datas = [NSMutableData new];
-
- }
-
- }
-
- -(Void) connection :( NSURLConnection *) connection didFailWithError: (NSError *) error {
-
- NSLog (@ "% @", [error localizedDescription]);
-
- [MBProgressHUD hideHUDForView: self. view animated: YES];
-
- }
-
-
- -(Void) connectionDidFinishLoading: (NSURLConnection *) connection {
-
- NSLog (@ "request completed ...");
-
- NSDictionary * dict = [NSJSONSerialization JSONObjectWithData: _ datas
-
- Options: NSJSONReadingAllowFragments error: nil];
-
- If (action = ACTION_QUERY) {// query processing
-
- [Self reloadView: dict];
-
- } Else if (action = ACTION_REMOVE) {// Delete
-
- NSString * message = @ "operation successful .";
-
- NSNumber * resultCodeObj = [dict objectForKey: @ "ResultCode"];
-
- If ([resultCodeObj integerValue] <0 ){
-
- Message = [resultCodeObj errorMessage];
-
- }
-
- UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @ "prompt message"
-
- Message: message
-
- Delegate: nil
-
- CancelButtonTitle: @ "OK"
-
- OtherButtonTitles: nil];
-
- [AlertView show];
-
- // Re-Query
-
- Action = ACTION_QUERY;
-
- [Self startRequest];
-
- }
-
- [MBProgressHUD hideHUDForView: self. view animated: YES];
-
- }
This article from the "Guan Dongsheng" blog, please be sure to keep this source http://2009315319.blog.51cto.com/701759/1174465