1.MBProgressHUD Pop-up window message interface, three ways:
The first way:
-(void) mytask{
Mbprogresshud *hud = [[Mbprogresshud alloc] initWithView:self.view];
[Self.view Addsubview:hud];
Hud.labeltext = @ "Automatic scanning";
[HUD showwhileexecuting: @selector (mytask) ontarget:self Withobject:nil Animated:yes];
Sleep (10);
[Self show];
}
-(void) Show {
[Self. HUD Removefromsuperview];
Testviewcontroller *test = [[Testviewcontroller alloc]init];
[Self presentviewcontroller:test animated:yes completion:nil];
}
The second way: (a function that uses a callback inside the MB)
A callback method is used
-(void) mytask1{
int duration = 5;
Mbprogresshud *hud = [[Mbprogresshud Alloc]initwithview:self.view];
[Self.view Addsubview:hud];
Hud.labeltext = @ "Logging in, please wait ...";
[HUD Showanimated:yes whileexecutingblock:^{
Sleep (duration);
} completionblock:^{
[HUD Removefromsuperview];
[Self show];
}];
}
-(void) Show {
[Self. HUD Removefromsuperview];
Testviewcontroller *test = [[Testviewcontroller alloc]init];
[Self presentviewcontroller:test animated:yes completion:nil];
}
The Third Way: (The whole screen is full of)
-(void) mytask2{
Self. HUD = [[Mbprogresshud alloc]init];
Self. HUD = [Mbprogresshud showmessage:@ "is querying, please wait a moment"];
Self. Hud.delegate = self;
Self.timer = [Nstimer scheduledtimerwithtimeinterval:10 target:self selector: @selector (show) Userinfo:nil Repeats:no] ;
}
-(void) Show {
[Self. HUD Removefromsuperview];
Testviewcontroller *test = [[Testviewcontroller alloc]init];
[Self presentviewcontroller:test animated:yes completion:nil];
}
#pragma mark-mbprogresshud (MB does not have this proxy method, a new method added)
-(void) hudviewwastapped{
NSLog (@ "Call the HUD proxy method");
[Self. HUD Removefromsuperview];
Self.timer = nil;
Self. HUD = nil;
}
How to use Mbprogress