Code Monkey home page Code Monkey logo

mbprogresshud's Introduction

MBProgressHUD

Build Status codecov.io SwiftPM compatible Carthage compatible Accio supported CocoaPods compatible License: MIT

MBProgressHUD is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features.

Requirements

MBProgressHUD works on iOS 9.0+. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation.framework
  • UIKit.framework
  • CoreGraphics.framework

You will need the latest developer tools in order to build MBProgressHUD. Old Xcode versions might work, but compatibility will not be explicitly maintained.

Adding MBProgressHUD to your project

CocoaPods

CocoaPods is the recommended way to add MBProgressHUD to your project.

  1. Add a pod entry for MBProgressHUD to your Podfile pod 'MBProgressHUD', '~> 1.2.0'
  2. Install the pod(s) by running pod install.
  3. Include MBProgressHUD wherever you need it with #import "MBProgressHUD.h".

Carthage

  1. Add MBProgressHUD to your Cartfile. e.g., github "jdg/MBProgressHUD" ~> 1.2.0
  2. Run carthage update
  3. Follow the rest of the standard Carthage installation instructions to add MBProgressHUD to your project.

SwiftPM / Accio

  1. Add the following to your Package.swift:
    .package(url: "https://github.com/jdg/MBProgressHUD.git", .upToNextMajor(from: "1.2.0")),
  2. Next, add MBProgressHUD to your App targets dependencies like so:
    .target(name: "App", dependencies: ["MBProgressHUD"]),
  3. Then open your project in Xcode 11+ (SwiftPM) or run accio update (Accio).

Source files

Alternatively you can directly add the MBProgressHUD.h and MBProgressHUD.m source files to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop MBProgressHUD.h and MBProgressHUD.m onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
  3. Include MBProgressHUD wherever you need it with #import "MBProgressHUD.h".

Static library

You can also add MBProgressHUD as a static library to your project or workspace.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop MBProgressHUD.xcodeproj onto your project or workspace (use the "Product Navigator view").
  3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add libMBProgressHUD.a. You might also need to add MBProgressHUD to the Target Dependencies list.
  4. Include MBProgressHUD wherever you need it with #import <MBProgressHUD/MBProgressHUD.h>.

Usage

The main guideline you need to follow when dealing with MBProgressHUD while running long-running tasks is keeping the main thread work-free, so the UI can be updated promptly. The recommended way of using MBProgressHUD is therefore to set it up on the main thread and then spinning the task, that you want to perform, off onto a new thread.

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
	// Do something...
	dispatch_async(dispatch_get_main_queue(), ^{
		[MBProgressHUD hideHUDForView:self.view animated:YES];
	});
});

You can add the HUD on any view or window. It is however a good idea to avoid adding the HUD to certain UIKit views with complex view hierarchies - like UITableView or UICollectionView. Those can mutate their subviews in unexpected ways and thereby break HUD display.

If you need to configure the HUD you can do this by using the MBProgressHUD reference that showHUDAddedTo:animated: returns.

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeAnnularDeterminate;
hud.label.text = @"Loading";
[self doSomethingInBackgroundWithProgressCallback:^(float progress) {
	hud.progress = progress;
} completionCallback:^{
	[hud hideAnimated:YES];
}];

You can also use a NSProgress object and MBProgressHUD will update itself when there is progress reported through that object.

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeAnnularDeterminate;
hud.label.text = @"Loading";
NSProgress *progress = [self doSomethingInBackgroundCompletion:^{
	[hud hideAnimated:YES];
}];
hud.progressObject = progress;

Keep in mind that UI updates, including calls to MBProgressHUD should always be done on the main thread.

If you need to run your long-running task in the main thread, you should perform it with a slight delay, so UIKit will have enough time to update the UI (i.e., draw the HUD) before you block the main thread with your task.

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
	// Do something...
	[MBProgressHUD hideHUDForView:self.view animated:YES];
});

You should be aware that any HUD updates issued inside the above block won't be displayed until the block completes.

For more examples, including how to use MBProgressHUD with asynchronous operations such as NSURLConnection, take a look at the bundled demo project. Extensive API documentation is provided in the header file (MBProgressHUD.h).

License

This code is distributed under the terms and conditions of the MIT license.

Change-log

A brief summary of each MBProgressHUD release can be found in the CHANGELOG.

Privacy

MBProgressHUD does not collect any data. See SDK Privacy Practices for more information.

mbprogresshud's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mbprogresshud's Issues

Memory leaks in ARC

Hi,
Thank you for supplying very useful code.
I am a newbie to github and I wonder if here is the right place to put this kind of post. Forgive me and delete the post if I am wrong.

Today I came across memory leaks related to progressHUD in ARC envrionment.
In my view controller, I download a somewhat big image. The code is as below.

[self.progressHUD showWhieExecuting:@selector(downloadImage)
onTarget:self
withObject:nil
animated:YES];

The process is nicely done. But when I close the view, the view controller's dealloc never called.
If I just call the downloadImage without using progressHUD, the dealloc method is called when closing the view.
I think the view instance is held by the progressHUD and is not be released? I modified MBProgressHUD.m as blow and the problem solved.

  • (void)cleanUp {
    :
    #if !__has_feature(objc_arc)
    [targetForExecution release];
    [objectForExecution release];
    #else <== Added this three lines.
    targetForExecution = nil; <==
    objectForExecution = nil; <==
    #endif
    ]

I am not a expert about Obj-C and ARC so I am not sure this is the right way.
Anyway I hope this helps.

Library target

  • refactor demo project
  • add a workspace
  • update documentation

UITableView headings shown on top of MBProgressHUD

So I have a subclass of UITableViewController that loads some data from the internet and uses MBProgressHUD during the loading process. I use the standard MBProgressHUD initialization.

    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];

    HUD.delegate = self;
    HUD.labelText = @"Loading";

    [HUD show:YES];

This is the result:

result.

Is there any way to resolve this issue, or should I just abandon MBProgressHUD?

Thanks!

Link to post on StackOverflow

Please use semantic version

Hi,

I’ve recently used MBProgressHUD with CocoaPods package manager.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, MBProgressHUD doesn't have semantic version tags. e.g. there are version number 0.41 and 0.5.

As 41 is larger than 5, CocoaPods will think 0.41 is actually a newer version. It would be grateful if next patch version could be called 0.5.1, and next minor version be 0.6.0, such that dependency can be resolved automatically.

multiline for labelText property required (again)

this feature was available earlier and I would love to have it back!

A good solution would add a property (BOOL) like textLabelMultiline, or property (int) textLabelNumberOfLines

otherwise the textLabel itself could be made public so that the numberOfLines can be set (and treated in layoutSubviews)

Memory Leaks on indicator

I discovered a mem leak when you init the indicator (row 133 MBProgressHud.m).
I guess an "[indicator release]" could fix that issue, as follows:

if (indicator) {
    [indicator removeFromSuperview];
    [indicator release];
}

Am I right?

Impossible to show detailsLabel with more than one line

I think that the detailsLabel height is being calculated in a wrong way because you use the current label height for the sizeWithFont method in stead of leaving the max height allowed.

Wrong way:
CGFloat maxHeight = frame.size.height - self.height - 2_margin;
CGSize labelSize = [detailsLabel.text sizeWithFont:detailsLabel.font constrainedToSize:CGSizeMake(frame.size.width - 4_margin, maxHeight) lineBreakMode:detailsLabel.lineBreakMode];

It should be:

CGFloat maxHeight = 200; // Or the max height we want to allow
CGSize labelSize = [detailsLabel.text sizeWithFont:detailsLabel.font constrainedToSize:CGSizeMake(frame.size.width - 4*margin, maxHeight) lineBreakMode:detailsLabel.lineBreakMode];

Memory leak in drawRect:(CGRect)rect

Found potential leak in MBProgressHUD.m : (void)drawRect(CGRect)rect

May wish to add:
CGColorSpaceRelease(colorSpace);
CGGradientRelease(gradient);

  • (void)drawRect:(CGRect)rect {

    CGContextRef context = UIGraphicsGetCurrentContext();

    if (dimBackground) {
    //Gradient colours
    size_t gradLocationsNum = 2;
    CGFloat gradLocations[2] = {0.0f, 1.0f};
    CGFloat gradColors[8] = {0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.75f};
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, gradColors, gradLocations, gradLocationsNum);

    //Gradient center
    CGPoint gradCenter= CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
    //Gradient radius
    float gradRadius = MIN(self.bounds.size.width , self.bounds.size.height) ;
    //Gradient draw
    CGContextDrawRadialGradient (context, gradient, gradCenter,
                                 0, gradCenter, gradRadius,
                                 kCGGradientDrawsAfterEndLocation);
    CGColorSpaceRelease(colorSpace);
    CGGradientRelease(gradient);
    

    } ...

Above Keyboard

Is there a way to show the HUD above the onscreen-keyboard?

The same situation,Second time be rejected because of used MBProgressHUD :(

stackoverflow url:
http://stackoverflow.com/questions/12575477/the-same-situation-second-time-be-rejected-because-of-used-mbprogresshud

Reasons for Rejection: The activity indicator spins indefinetely and the user can't access the content

The same situation,Second time be rejected because of used MBProgressHUD.

Who can tell me Uploaded to appstore app would be any different? I done various tests, such a problem did not appear in the local.

-----------------------------in my controller-----------------------------------

  • (void)downloadList
    {

    if (isLoading) {
    return;
    }

    isLoading = YES;

    //do something......

    //show the progressbar based on MBProgressHUD
    [[MyDelegate getAppDelegate] showProgressBarForTarget:self whileExecuting:@selector(showProgressBarForLoading)];
    }
    }

  • (void)showProgressBarForLoading
    {
    while (isLoading) {
    //i++;
    continue;
    }
    }

  • (void)downloadListDidReceive:(XGooConnection_)sender obj:(NSObject_)obj
    {
    //do something......

    isLoading = NO;

}
-----------------------------in my AppDelegate-------------------------------

  • (void)showProgressBarForTarget:(id)target whileExecuting:(SEL)theSelector
    {
    UIViewController *controller = [splitViewController.viewControllers objectAtIndex:0];

    HUD = [[MBProgressHUD alloc] initWithView:controller.view];
    [controller.view addSubview:HUD];

    HUD.delegate = self;

    // Show the HUD while the provided method executes in a new thread
    [HUD showWhileExecuting:theSelector onTarget:target withObject:nil animated:YES];
    }
    -----------------------------Reasons for Rejection detail-------------------------------------

The most recent version of your app has been rejected........

Reasons for Rejection:

The steps to reproduce are:

Launch the app
Select the Menu button at the top left corner
Select a menu item
The activity indicator spins indefinetely and the user can't access the content

SIGBART when tilt device; not when flat on table

My app keeps crashing ONLY when I move or tilt the device; not when the device is flat on the table and it SEEMS like the cause is layoutSubviews on line 355

You can see the crash log here: https://gist.github.com/1171118

Here's one place where I use the HUD:
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.view];
hud.labelText = @"Loading...";
[self.view.window addSubview:hud];
[hud showWhileExecuting:@selector(getResultsAndShowSearchResults) onTarget:self withObject:nil animated:YES];
[hud release];

And here's another:
-(IBAction)didChooseToReadFeatured {
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.view];
hud.labelText = @"Downloading...";
[self.view.window addSubview:hud];
[hud showWhileExecuting:@selector(getDataAndDisplay) onTarget:self withObject:nil animated:YES];
[hud setDelegate:self];
}

-(void)getDataAndDisplay {
self.reader = [[[ReaderViewController alloc] init] autorelease];
}

  • (void)hudWasHidden:(MBProgressHUD *)hud {
    [self presentModalViewController:self.reader animated:YES];
    [hud release];
    }

Any help would be much appreciated! Thanks!

Crash when calling hide: without first calling show:

It would appear that calling hide: without first calling show: causes a crash at the following line:

self.showStarted = nil;

It seems to be attempting to call a deallocated instance:

*** -[MBProgressHUD setShowStarted:]: message sent to deallocated instance

I haven't had time to look at exactly why this is happening but a quick potential fix is adding a check around the call:

if (showStarted) {
 self.showStarted = nil;
}

SIGSEGV -[MBProgressHUD animationFinished:finished:context:]

I'm having this crash a lot... Anyone can help me? Any ideas?

SIGSEGV
-[MBProgressHUD animationFinished:finished:context:]

Thread: Unknown Name (Crashed)
Skip to register data

0 libobjc.A.dylib 0x37d08f78 objc_msgSend + 15
1 LookdoDia 0x000b098d -[MBProgressHUD animationFinished:finished:context:] + 36
2 UIKit 0x333b0aab -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 470
3 UIKit 0x333b63d5 -[UIViewAnimationState animationDidStop:finished:] + 52
4 QuartzCore 0x327bcc2f _ZN2CA5Layer23run_animation_callbacksEPv + 202
5 libdispatch.dylib 0x347f6ee7 _dispatch_main_queue_callback_4CF$VARIANT$mp + 194
6 CoreFoundation 0x3593a2ad __CFRunLoopRun + 1268
7 CoreFoundation 0x358bd4a5 CFRunLoopRunSpecific + 300
8 CoreFoundation 0x358bd36d CFRunLoopRunInMode + 104
9 GraphicsServices 0x37559439 GSEventRunModal + 136
10 UIKit 0x333c9cd5 UIApplicationMain + 1080
11 LookdoDia 0x0008a991 main + 80
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3620d3a8 kevent + 24
1 libdispatch.dylib 0x347f7c29 _dispatch_mgr_wakeup + 0
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3620d004 mach_msg_trap + 20
1 CoreFoundation 0x3593b3f3 __CFRunLoopServiceMachPort + 126
2 CoreFoundation 0x3593a12b __CFRunLoopRun + 882
3 CoreFoundation 0x358bd4a5 CFRunLoopRunSpecific + 300
4 CoreFoundation 0x358bd36d CFRunLoopRunInMode + 104
5 WebCore 0x317bcca3 _ZL12RunWebThreadPv + 402
6 libsystem_c.dylib 0x32d2a735 _pthread_start + 320
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3620d004 mach_msg_trap + 20
1 CoreFoundation 0x3593b3f3 CFRunLoopServiceMachPort + 126
2 CoreFoundation 0x3593a12b __CFRunLoopRun + 882
3 CoreFoundation 0x358bd4a5 CFRunLoopRunSpecific + 300
4 CoreFoundation 0x358bd36d CFRunLoopRunInMode + 104
5 Foundation 0x353f6bb9 +[NSURLConnection(Loader) _resourceLoadLoop:] + 308
6 Foundation 0x353f6a81 -[NSThread main] + 72
7 Foundation 0x3548a591 __NSThread__main
+ 1048
8 libsystem_c.dylib 0x32d2a735 _pthread_start + 320
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3621d570 __select + 20
1 libsystem_c.dylib 0x32d2a735 _pthread_start + 320
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3621d068 psynch_cvwait + 24
1 libsystem_c.dylib 0x32d2a7c9 pthread_cond_wait + 40
2 Foundation 0x353f6cc1 -[NSCondition wait] + 196
3 LookdoDia 0x001b222b -[PFCommandCache runLoop] + 494
4 Foundation 0x353f6a81 -[NSThread main] + 72
5 Foundation 0x3548a591 __NSThread__main
+ 1048
6 libsystem_c.dylib 0x32d2a735 _pthread_start + 320
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3620d004 mach_msg_trap + 20
1 CoreFoundation 0x3593b3f3 CFRunLoopServiceMachPort + 126
2 CoreFoundation 0x3593a12b __CFRunLoopRun + 882
3 CoreFoundation 0x358bd4a5 CFRunLoopRunSpecific + 300
4 CoreFoundation 0x3593a44b CFRunLoopRun + 98
5 LookdoDia 0x000d0e3d +[ASIHTTPRequest runRequests] + 124
6 Foundation 0x353f6a81 -[NSThread main] + 72
7 Foundation 0x3548a591 __NSThread__main
+ 1048
8 libsystem_c.dylib 0x32d2a735 _pthread_start + 320
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3621d068 __psynch_cvwait + 24
1 libsystem_c.dylib 0x32d2a7c9 pthread_cond_wait + 40
2 CoreMedia 0x30a9e86f FigSemaphoreWaitRelative + 274
3 MediaToolbox 0x367c13ed fpa_AsyncMovieControlThread + 28
4 CoreMedia 0x30abd8bb figThreadMain + 174
5 libsystem_c.dylib 0x32d2a735 _pthread_start + 320
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3621dcd4 __workq_kernreturn + 8
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3621dcd4 __workq_kernreturn + 8
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3621dcd4 __workq_kernreturn + 8
Thread: Unknown Name

0 libsystem_kernel.dylib 0x3621dcd4 __workq_kernreturn + 8
Register data from crashed thread

r0: 0xed8f9e0 r1: 0x374f44f6 r2: 0x1e668f r3: 0x1
r4: 0x0 r5: 0x1e894c r6: 0xedc48e0 r7: 0x2fe85eac
r8: 0x1 r9: 0xdd3d13d r10: 0x0 r11: 0x3
sp: 0x2fe85e94 lr: 0xb09db pc: 0x37d08f78 cpsr: 0x200f0030

UITableViewController

I've noticed when calling showHUDAddedTo:self.view on a UITableViewController, it is not disabling touch events to the table. Is this by design?

Regarding orientation

Hello,

I'm currently using your progressHUD and first of all thanks for a very nice solution.

I found some problems regarding orientation in my project when using the HUD on the mainwindow.
After some debugging the solution for me was to change the observer name you register to.

FROM
//     UIDeviceOrientationDidChangeNotification

TO
// UIApplicationDidChangeStatusBarOrientationNotification

I also noticed that the "UIDeviceOrientationDidChangeNotification" gets called many times, even when not fully rotating.

Feel free to give me any feedback

Best regards,
Oli

MBProgressHUD.h file not found when archiving for test flight

I can build for debugging just fine. I've triple checked that the static library is included in the build phases settings for the project. I've also tried other things like header include paths and such to no avail.

When I try to build an IPA for test flight, I get an error: #import <MBProgressHUD/MBProgressHUD.h>

I've been able to build an IPA before, but it didn't implement/use the MBProgressHUD static library before.

I can include the the header and code file manually instead of statically linking it, but I prefer to know what's going on here.

Thanks.

PS - I used the "Static Library" instructions given https://github.com/jdg/MBProgressHUD

http://stackoverflow.com/questions/13808853/why-is-a-static-librarys-header-file-not-found-for-archiving

dimBackground on rotation

Hi,

when you are using device in landscape orientation and dimBackground is set for YES, dimmed background will always be drawn in portrait position. That makes not dimmed rectangles on left and right sides. I made little changes to fix it, I don't know if it's suitable for pull request, because its 3 lines of code.. So here they are:
in function initWithFrame at line 265 I added flexible height and width to autoresizingMask:

self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

and in function deviceOrientationDidChange at line 625 I added setNeedsLayout and setNeedsDisplay:

- (void)deviceOrientationDidChange:(NSNotification *)notification { 
    if (!self.superview) {
        return;
    }
    if ([self.superview isKindOfClass:[UIWindow class]]) {
        [self setTransformForCurrentOrientation:YES];
    }
    [self performSelectorOnMainThread:@selector(setNeedsLayout) withObject:nil waitUntilDone:NO];
    [self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
}

Maybe it's not best solution, but it's fastest.

couple of small bugfixes

excellent work. a very nice job.

i have a couple of possible fixes to propose.

one is to have color be a UIColor instead of a CGColorRef . this allows for quite a bit simpler use in code that doesn't normally deal with CG much ... and i discovered in attempting to use the CGColorRef in an ARC-supported program that i had to keep the UIColor hanging around for the duration of the HUD. so, by changing it to (retain) UIColor, this isn't necessary. it only requires one change internally to refer to color.CGColor … and, of course, unfortunately, a change to any external users. i'd be happy to figure out a backward compatibile interface (perhaps calling the UIColor property uiColor ?)

the second has to do with performing a UIGraphicsPushContext() at the beginning of drawRect: and then a UIGraphicsPopContext() at the end. this seems safest w.r.t. making sure the calling context isn't affected by MBProgressHUD .

i can push my branch to your github clone if you like, or if you have another idea for reviewing the changes, let me know.

Resident Memory Bug

MBProgressHUD has been causing some memory issues within my project, and is reproducible within the Demo project. Whenever the HUD is shown / dismissed, there is an increase in the Dirty Memory Size (Visible within VM Tracker), and this is seemingly never released. Leading to a recurring growth in memory, eventually leading to memory warnings and the app being closed due to memory warnings.

See http://d.pr/i/Kr0x (Every step up (after the initial spike) in the Dirty Size graph, is showing the progress HUD, when the hud is closed the memory is not cleared and keeps increasing.

Whilst in this demo project the amount of memory is small, when using a custom view, with both label and details label, the memory consumed can be significantly higher.

Loading circle dont appear during UIWebView loading

How to show loading while web view is loading data?

  • (void)viewDidLoad
    {
    [super viewDidLoad];

    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];

    HUD.dimBackground = YES;

    // Regiser for HUD callbacks so we can remove it from the window at the right time
    HUD.delegate = self;

    // Show the HUD while the provided method executes in a new thread
    [HUD showWhileExecuting:@selector(loadContent) onTarget:self withObject:nil animated:YES];
    }

-(void)loadContent{

NSString *path = [NSString stringWithFormat:@"http://abc.com/test/test.php?name=John"];

NSURL *url0 = [NSURL URLWithString:path];
request = [NSURLRequest requestWithURL:url0];
[_webViewDzivnieks loadRequest:request];

}

Crash using MBProgressHUD with latest Cordova (Phonegap)

I get this xcode crash when trying to use your component :

*** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <MBProgressHUD 0xde68840> for the key path "mode" from <MBProgressHUD 0xde68840> because it is not registered as an observer.'

Any ideas?

*** -[MBProgressHUD hideDelayed:]: message sent to deallocated instance 0xc6fa290

Hi!

I'm getting this error:

*** -[MBProgressHUD hideDelayed:]: message sent to deallocated instance 0xc6fa290

A lot!

I have:
HUD.delegate = nil;
[HUD release];

In dealloc method and I'm trying to use:

[HUD show:NO];
and
[HUD hide:YES];

To hide HUD but it keeps giving me this error.

I'm using UINavigationController and this error appears when I change from a view to another.

How to solve it? Thank you!

HUD not changing label second time

I'm using MBProgressHUD in our teaching App, which is tab bar navigated.

The user will come from a tableview via Urban Airship's storefront directly to the UA detail view.
Once buy is clicked I bring on HUD with

HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];
[self.view.window addSubview:HUD];

It is using the showWhileExecuting statement.

It goes through three while statements to change from "Connecting" to "Downloading" to "Unpacking".
All perfectly right.

Here comes the problem...
The second time I do this the label text will not change. It is stuck on "Connecting".
I can see in the NSLog that it is going through the other loops. If I try to change the Mode, the app crashes. But only the second time, and any subsequent uses. If I kill the App everything works again for the first time.

I am using ARC, is there an issue where I', not clearing the HUD properly and something is left hanging?

change hud mode in NSConnection messages

While implementing the HUD for NSConnection like it your demo I noticed that the mode wouldn't change until hideWithDelay was called.

To change the mode I had to test for progress to be > 0.99 in the didReceiveData method. I then changed the mode.

In my connection did finishing loading I am unzipping a file and before the unzip took place I would change the mode, but it would not take effect until the unzipping was done and hideWithDelay was called.

I tested it by removing my unzipping code and placing a sleep for 3 seconds and changing the label text before and after the sleep. the label text was always the text updated after the sleep was called.

Its very odd.

Just thought I would put this out there.

Orientation change animation

When the device changes its orientation the hud does rotate appropriately, but the animation is a bit faster then the animation of the view behind it. It's ok in most case, but when you set dimBackground to YES you can defintely see that something is wrong.

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
hud.dimBackground = YES;

That's it

MBProgressHUD addSubview in Window - don't rotate

Hi.
Your work is very good!
I've found a bag.
When i add the HUD in AppDelegate Window, the HUD view don't rotate.
I've activate the function "setTransformForCurrentOrientation" but function only work in a view.
You can found a solution. Bye!

Solve "PerformSelector may cause memory leak..." warning

Hi!

To fix this warnings only is necessary to change all the "[targetForExecution performSelector:methodForExecution withObject:objectForExecution];" calls by "[targetForExecution performSelectorInBackground:methodForExecution withObject:objectForExecution];" if you want to execute the task in background or "performSelectorOnMainThread" if you want to execute the task in the GUI thread.

Greetings!

Private API

roundedRectBezierPath:withRoundedCorners:withCornerRadius: is private API and will result in an App rejection in the Apple approval process since they are testing now automatically for private api use.

My app was rejected right away since they test automatically.

possible issue about indicator

I am using a modified edition of MBProgressHUD (a little old), so I just want to ask if the following questions is nonsense:

  1. I am using the MBProgressHUDModeInDeterminate mode so the indicator is always
    self.indicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
    since it is autoreleased, and most of time it will be set to in in selector "cleanup", it is still a little confusing that
    [indicator release] is in selector dealloc .
  2. I found an abuse of using MBProgressHUD in our code: it alloc a new HUD at the end of another HUD's protocol hudWasHidden: . and it causes crashes on my iPad2(4.3.3), but works fine on iPhone4(4.3) and iPhone 3G(4.2.1)
    the reason is that it execute "cleanUp" first, set indicator to nil, then calls layoutSubviews. then the indicator.bounds is unavailable and causes crash. i just add
    if(!self.indicator) return;
    to line 309. Is it OK?

Thanks for reviewing.

Changing customView after having shown the HUD once has no effect

Changing customView after having shown the HUD once has no effect. I think the customView setter should invoke updateIndicators, just like the mode setter does.

I don't submit a pull request because I don't know how to do this correctly, since customView is an atomic property. (I don't see why it is atomic though)

Methods declared twice

Hi,

The following methods are declared twice in the private interface for MBProgressHUD

  • (void)cleanUp;
  • (void)launchExecution;

Kind Regards,

Jasper

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.