Loading tips for IOS Mbprogresshud with Backplane
Last Update:2016-03-21
Source: Internet
Author: User
<span id="Label3"></p><p><p>Article from: http://blog.csdn.net/ryantang03/article/details/7877120<br></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;">Mbprogresshud is an open source project that implements a number of Style prompt boxes that are simple, easy to use, and can be customized for the displayed content, are powerful, and are used in many Projects. To GitHub can be downloaded to the project source code <span class="s1">Https://github.com/jdg/MBProgressHUD</span>, After downloading the MBProgressHUD.h and mbprogresshud.m directly into the project, do not forget to choose to copy to the Project. You can start using the import header file where you need to use it. First look at the Project:</span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;"><br></span></p></p><p class="p1"><p class="p1"></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;">Next is the entire demo of the full interface, here I only choose a few common dialog boxes, other styles in the source provided by the demo can be found, to use the direct reference can Be.</span></p></p><p><p><span style="white-space: pre;"><span style="white-space: pre;"><br></span></span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;">Next directly on the code, the header file section:</span></p></p><p class="p1"><p class="p1"></p></p><strong><strong>[cpp]</strong></strong>View Plaincopy <ol class="dp-cpp" start="1"> <li class="alt"><li class="alt"><span class="preprocessor">#import <UIKit/UIKit.h></span></li></li> <li><li><span class="preprocessor">#import "MBProgressHUD.h"</span></li></li> <li class="alt"><li class="alt"></li></li> <li><li>@interface Viewcontroller:uiviewcontroller</li></li> <li class="alt"><li class="alt">{</li></li> <li><li><span class="comment">//hud (head-up display, meaning the meaning of the heads Up)</span></li></li> <li class="alt"><li class="alt">Mbprogresshud *hud;</li></li> <li><li>}</li></li> <li class="alt"><li class="alt"></li></li> <li><li>-(ibaction) showtextdialog: (id) sender;</li></li> <li class="alt"><li class="alt">-(ibaction) showprogressdialog: (id) sender;</li></li> <li><li>-(ibaction) showProgressDialog2: (id) sender;</li></li> <li class="alt"><li class="alt">-(ibaction) showcustomdialog: (id) sender;</li></li> <li><li>-(ibaction) showalltextdialog: (id) sender;</li></li> <li class="alt"><li class="alt"></li></li> <li><li>@end</li></li> </ol><p><p><span style="white-space: pre;"><span style="white-space: pre;"><br><span style="font-family: Comic Sans MS; font-size: 18px;">Implementation file (button implementation section):</span></span></span></p></p><p class="p1"><p class="p1"></p></p><strong><strong>[cpp]</strong></strong>View Plaincopy <ol class="dp-cpp" start="1"> <li class="alt"><li class="alt">-(ibaction) showtextdialog: (id) Sender {</li></li> <li><li><span class="comment">//initialize The Progress box in the current view</span></li></li> <li class="alt"><li class="alt">HUD = [[mbprogresshud alloc] initWithView:self.view];</li></li> <li><li>[self.view addsubview:hud];</li></li> <li class="alt"><li class="alt"></li></li> <li><li><span class="comment">//if This property is set, the current view is placed in the background</span></li></li> <li class="alt"><li class="alt">Hud.dimbackground = YES;</li></li> <li><li></li></li> <li class="alt"><li class="alt"><span class="comment">//set dialog box text</span></li></li> <li><li>Hud.labeltext = @<span class="string">"please Wait a moment"; </span></li></li> <li class="alt"><li class="alt"></li></li> <li><li><span class="comment">//display dialog Box</span></li></li> <li class="alt"><li class="alt">[HUD Showanimated:yes whileexecutingblock:^{</li></li> <li><li><span class="comment">actions to be performed when The//dialog box is displayed</span></li></li> <li class="alt"><li class="alt">Sleep (3);</li></li> <li><li>} completionblock:^{</li></li> <li class="alt"><li class="alt"><span class="comment">//cancel The dialog after the operation has finished executing</span></li></li> <li><li>[HUD removefromsuperview];</li></li> <li class="alt"><li class="alt">[HUD release];</li></li> <li><li>HUD = nil;</li></li> <li class="alt"><li class="alt">}];</li></li> <li><li>}</li></li> <li class="alt"><li class="alt"></li></li> <li><li>-(ibaction) showprogressdialog: (id) Sender {</li></li> <li class="alt"><li class="alt">HUD = [[mbprogresshud alloc] initWithView:self.view];</li></li> <li><li>[self.view addsubview:hud];</li></li> <li class="alt"><li class="alt">Hud.labeltext = @<span class="string">"loading"; </span></li></li> <li><li></li></li> <li class="alt"><li class="alt"><span class="comment">//setup mode is Progress box-shaped</span></li></li> <li><li>Hud.mode = mbprogresshudmodedeterminate;</li></li> <li class="alt"><li class="alt">[HUD Showanimated:yes whileexecutingblock:^{</li></li> <li><li><span class="datatypes">Float progress = 0.0f; </span></li></li> <li class="alt"><li class="alt">while <span class="keyword">(progress < 1.0f) {</span></li></li> <li><li>Progress + = 0.01f;</li></li> <li class="alt"><li class="alt">Hud.progress = progress;</li></li> <li><li>Usleep (50000);</li></li> <li class="alt"><li class="alt">}</li></li> <li><li>} completionblock:^{</li></li> <li class="alt"><li class="alt">[HUD removefromsuperview];</li></li> <li><li>[HUD release];</li></li> <li class="alt"><li class="alt">HUD = nil;</li></li> <li><li>}];</li></li> <li class="alt"><li class="alt">}</li></li> <li><li></li></li> <li class="alt"><li class="alt">-(ibaction) showProgressDialog2: (id) Sender {</li></li> <li><li>HUD = [[mbprogresshud alloc] initWithView:self.view];</li></li> <li class="alt"><li class="alt">[self.view addsubview:hud];</li></li> <li><li>Hud.labeltext = @<span class="string">"loading"; </span></li></li> <li class="alt"><li class="alt">Hud.mode = mbprogresshudmodeannulardeterminate;</li></li> <li><li></li></li> <li class="alt"><li class="alt">[HUD Showanimated:yes whileexecutingblock:^{</li></li> <li><li><span class="datatypes">Float progress = 0.0f; </span></li></li> <li class="alt"><li class="alt">while <span class="keyword">(progress < 1.0f) {</span></li></li> <li><li>Progress + = 0.01f;</li></li> <li class="alt"><li class="alt">Hud.progress = progress;</li></li> <li><li>Usleep (50000);</li></li> <li class="alt"><li class="alt">}</li></li> <li><li>} completionblock:^{</li></li> <li class="alt"><li class="alt">[HUD removefromsuperview];</li></li> <li><li>[HUD release];</li></li> <li class="alt"><li class="alt">HUD = nil;</li></li> <li><li>}];</li></li> <li class="alt"><li class="alt">}</li></li> <li><li></li></li> <li class="alt"><li class="alt">-(ibaction) showcustomdialog: (id) Sender {</li></li> <li><li>HUD = [[mbprogresshud alloc] initWithView:self.view];</li></li> <li class="alt"><li class="alt">[self.view addsubview:hud];</li></li> <li><li>Hud.labeltext = @<span class="string">"operation succeeded"; </span></li></li> <li class="alt"><li class="alt">Hud.mode = mbprogresshudmodecustomview;</li></li> <li><li>Hud.customview = [[[uiimageview alloc] initwithimage:[uiimage imagenamed:@<span class="string">"checkmark"]] autorelease]; </span></li></li> <li class="alt"><li class="alt">[HUD Showanimated:yes whileexecutingblock:^{</li></li> <li><li>Sleep (2);</li></li> <li class="alt"><li class="alt">} completionblock:^{</li></li> <li><li>[HUD removefromsuperview];</li></li> <li class="alt"><li class="alt">[HUD release];</li></li> <li><li>HUD = nil;</li></li> <li class="alt"><li class="alt">}];</li></li> <li><li></li></li> <li class="alt"><li class="alt">}</li></li> <li><li></li></li> <li class="alt"><li class="alt">-(ibaction) showalltextdialog: (id) Sender {</li></li> <li><li>HUD = [[mbprogresshud alloc] initWithView:self.view];</li></li> <li class="alt"><li class="alt">[self.view addsubview:hud];</li></li> <li><li>Hud.labeltext = @<span class="string">"operation succeeded"; </span></li></li> <li class="alt"><li class="alt">Hud.mode = mbprogresshudmodetext;</li></li> <li><li></li></li> <li class="alt"><li class="alt"><span class="comment">//specify The offset of the x and Y axes from the center point, and display in the middle of the screen if not specified</span></li></li> <li><li><span class="comment">Hud.yoffset = 150.0f;</span></li></li> <li class="alt"><li class="alt"><span class="comment">Hud.xoffset = 100.0f;</span></li></li> <li><li></li></li> <li class="alt"><li class="alt">[HUD Showanimated:yes whileexecutingblock:^{</li></li> <li><li>Sleep (2);</li></li> <li class="alt"><li class="alt">} completionblock:^{</li></li> <li><li>[HUD removefromsuperview];</li></li> <li class="alt"><li class="alt">[HUD release];</li></li> <li><li>HUD = nil;</li></li> <li class="alt"><li class="alt">}];</li></li> <li><li>}</li></li> </ol><p><p><span style="white-space: pre;"><span style="white-space: pre;"><span style="font-family: Comic Sans MS; font-size: 18px;"><br>The following results are achieved in turn:</span></span></span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;"><br></span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;"><br></span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;"><br></span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;">The following effect is similar to a toast in android:</span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;"><span style="white-space: pre;"><br></span></span></p></p><p class="p1"><p class="p1"><span style="font-family: Comic Sans MS; font-size: 18px;">The above is a brief introduction to the use of mbprogresshud, which are used in the form of block, so write code to more intuitive and more efficient.</span></p></p><p><p>Loading tips for IOS Mbprogresshud with Backplane</p></p></span>