How to use Mbprogress

Source: Internet
Author: User

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

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.