IOS network programming-mbprogresshud wait indicator

Source: Internet
Author: User

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.

 

 

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 of the master View Controller masterviewcontroller. M.CodeNote the following:

-( 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 address>  " , @"  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 address> " , @"  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: _ datasoptions: 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  : Nilcancelbuttontitle: @ "OK" otherbuttontitles: Nil]; [alertview show];  //  Re-Query  Action = Action_query; [self startrequest];} [mbprogresshud hidehudforview: Self. View animated: Yes];} 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.