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];}