Giter VIP home page Giter VIP 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.

NOTE: The class has recently undergone a major rewrite. The old version is available in the legacy branch, should you need it.

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, inclining 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.

mbprogresshud's People

Contributors

4brunu avatar arsonik avatar bhargavms avatar briansoule avatar dontangg avatar emreberge avatar epacces avatar fjolnir avatar foolish-boy avatar hsoi avatar jdg avatar jeehut avatar lutzifer avatar matej avatar mattjgalloway avatar mattrubin avatar mrackwitz avatar nanoant avatar per-gron avatar putermancer avatar readmecritic avatar renebigot avatar roger-ijr avatar ruggeri avatar runeb avatar syuilo avatar tewha avatar vyazovoy avatar yas375 avatar zenwheel avatar

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

mbprogresshud's Issues

Crashing Due to NaN values in [MBProgressHUD layoutSubviews]

I'm seeing irregular crashing from trying to set the frame to values that are NaN around line 350 in MBProgressHUD.m. The indFrame's height is a NaN value and causes a crash. The issues occurs when I'm using the MBProgressHUD to do repeated actions.

How to reproduce: Repeatedly press a button that does background work with MBProgessHUD's showWillExecuting method.

    // Set the label position and dimensions
    CGRect lFrame = CGRectMake(floor((frame.size.width - lWidth) / 2) + xOffset,
                               floor(indFrame.origin.y + indFrame.size.height + PADDING),
                               lWidth, lHeight);
    ALog(@"lFrame: %@", NSStringFromCGRect(lFrame));
    label.frame = lFrame;            <=== CRASH HERE

My code to create a MBProgressHUD is here:

- (void)evolveButtonPressed:(id)sender {
   [self cleanupActivityPopup]; // Cleanup any old MBProgresHUD before creating a new one
   activityPopup = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
    // Add to screen
    [self.navigationController.view addSubview:activityPopup];
    activityPopup.delegate = self;
    activityPopup.labelText = @"Evolving";
    [activityPopup showWhileExecuting:@selector(evolveInBackground) onTarget:self withObject:nil animated:YES];
}

- (void)evolveInBackground {
    // Do evolution in background

    // Update GUI on main thread
    [self performSelectorOnMainThread:@selector(updateEvolveOnMainThread) withObject:nil waitUntilDone:NO];
}

- (void)updateEvolveOnMainThread {
    // Reset buttons
    [self reload];
}
- (void)hudWasHidden {
    // Remove HUD from screen when the HUD was hidded
    [self cleanupActivityPopup];
}

- (void)cleanupActivityPopup {
    ALog();
    if(activityPopup) {
        [activityPopup removeFromSuperview];
        activityPopup.delegate = nil;
        [activityPopup release];
        activityPopup = nil; 
    }
}

Stack trace:
2011-06-03 10:09:49.917 Artwork Evolution[2138:707] -[MBProgressHUD layoutSubviews] [Line 304] indFrame: {{0, 0}, {nan, nan}}
2011-06-03 10:09:49.919 Artwork Evolution[2138:707] -[MBProgressHUD layoutSubviews] [Line 354] lFrame: {{300, nan}, {167, 20}}
2011-06-03 10:09:49.923 Artwork Evolution[2138:707] void uncaughtExceptionHandler(NSException ) [Line 345]
2011-06-03 10:09:49.964 Artwork Evolution[2138:707] *
* Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [383.5 nan]'
*** Call stack at first throw:
(
0 CoreFoundation 0x3216064f exceptionPreprocess + 114
1 libobjc.A.dylib 0x31b64c5d objc_exception_throw + 24
2 CoreFoundation 0x32160491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x321604cb +[NSException raise:format:] + 34
4 QuartzCore 0x36f5a61d _ZL18CALayerSetPositionP7CALayerRKN2CA4Vec2IdEEb + 140
5 QuartzCore 0x36f5a58b -[CALayer setPosition:] + 38
6 QuartzCore 0x36f5a4d7 -[CALayer setFrame:] + 390
7 UIKit 0x36a91455 -[UIView(Geometry) setFrame:] + 188
8 UIKit 0x36a920fb -[UILabel setFrame:] + 210
9 Artwork Evolution 0x0001d671 -[MBProgressHUD layoutSubviews] + 1120
10 UIKit 0x36a915fb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
11 CoreFoundation 0x320cdf03 -[NSObject(NSObject) performSelector:withObject:] + 22
12 QuartzCore 0x36f5bbb5 -[CALayer layoutSublayers] + 120
13 QuartzCore 0x36f5b96d CALayerLayoutIfNeeded + 184
14 QuartzCore 0x36f611c5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 212
15 QuartzCore 0x36f60fd7 _ZN2CA11Transaction6commitEv + 190
16 QuartzCore 0x36f5a055 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 56
17 CoreFoundation 0x32137a35 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 16
18 CoreFoundation 0x32139465 __CFRunLoopDoObservers + 412
19 CoreFoundation 0x3213a75b __CFRunLoopRun + 854
20 CoreFoundation 0x320caec3 CFRunLoopRunSpecific + 230
21 CoreFoundation 0x320cadcb CFRunLoopRunInMode + 58
22 GraphicsServices 0x33fe541f GSEventRunModal + 114
23 GraphicsServices 0x33fe54cb GSEventRun + 62
24 UIKit 0x36abad69 -[UIApplication _run] + 404
25 UIKit 0x36ab8807 UIApplicationMain + 670
26 Artwork Evolution 0x00002313 main + 74
27 Artwork Evolution 0x000022c4 start + 40
)
terminate called after throwing an instance of 'NSException'

[Suggestion]: Multiline text

It would we nice if the label and the details label would support multiline text so that more text can fit in those.

MBProgressHUD doesn't show when doing background process

I have implement MBProgressHUD in my app.
user select a tableViewCell and meanWhile a heavy Task will invoke to process text and prepare the detailsView. here I want to show an ActivityIndicator. but activity indicator won't appear until detailsViewController is going to push to the view!

I'm confused why it behave likes this!
you can download sample app from here (67 KB)

http://www.mediafire.com/download/decvu7uig9r6v1a/pageBasedApp.zip

(DataViewController *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard
{
[MBProgressHUD showHUDAddedTo:topView animated:YES];
sema = dispatch_semaphore_create(0);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
//here we do the heavy job
[self processText];

});
//I have used semaphore to let the data be prepared. if data is not ready startinViewcontroller will be nill and app will carsh
NSLog(@"waiting for semaphore");
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
NSLog(@"semaphore recieved");
[MBProgressHUD hideHUDForView:topView animated:YES];

.
.
.
.
}
Submit new issue

Status API Training Shop Blog About © 2013 GitHub, Inc. Terms Privacy Security Contact

Rotate on Device Rotation

Is there any way to rotate the HUD view on a device rotation. The problem I think is that the HUD view is attached to the window and the window method does not rotate view…viewControllers do.

Any ideas?

Unnecessary Code in deviceOrientationDidChange

Are the following lines in - (void)deviceOrientationDidChange:(NSNotification *)notification necessary?

// Stay in sync with the parent view (make sure we cover it fully)
CGRect theBounds = self.superview.bounds;
self.frame = self.superview.bounds;
[self setNeedsDisplay];

I ask because the hud view has autorizing options set when it is created, so will always resize when rotated.

In addition in my particular app (separate view for portrait/landscape and lots of frame setting) these lines break my views. Removing them has no ill effects.

Michael.

[Suggestion/ Interest Check] Tap To Cancel functionality

Would a pull request for a simple to use tap to cancel addition be accepted? I've done this in a project I'm working on, and I think I could pretty easily implement this on the main class or as a category.

Would you be open to a pull request for this?

I know that you have offered users a way to set this up in #41 and #46. I'm basically using this method, but this would make it easier for others in the future.

threading

How can I do this with [NSThread detachNewThreadSelector:@selector(threadedDownload) toTarget:self withObject:nil];

DEMO: XIB Compiler Errors

Can't open or compile xib files with Xcode Version 4.6.3.
".../MBProgressHUD/Demo/en.lproj/MainWindow.xib: The document "MainWindow.xib" could not be opened. Could not read archive. Please use a newer version of Xcode. Consider changing the document's Development Target to preserve compatibility."

Demo.app crashes

There is an issue with adding the MBProgressHUD to views (especially when doing it with scrollviews). When added to a UIScrollView in landscape mode, the HUD does not block input for the whole scroll view content size. By not doing so, other actions can be triggered and apps can be crashed. :)

To reproduce:

  1. start the app
  2. put it in landscape mode
  3. tap on any button that does not have "window" in it's title
  4. scroll the view up or down (must be outside of the HUDs input blocking)
  5. press another button, that does not have "window" in it's title
  6. repeat steps 4 and 5 if necessary
  7. when you have two HUDs on screen, and they should disappear, the app crashes

Here is what I get with NSZombieEnabled:

HudDemo[95461:5f07] *** -[MBProgressHUD setProgress:]: message sent to deallocated instance 0x5d17cd0

Trouble Compiling in XCode 3.2.6

After the code rewrite the 4.2/4.3 compatibility is broken. I have git pulled the copy today, I get 70 errors:

/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:65: error: inconsistent instance variable specification
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD initWithFrame:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:179: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:179: error: (Each undeclared identifier is reported only once
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:179: error: for each function it appears in.)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD dealloc]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:208: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:209: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD show:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:223: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD hide:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:237: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD handleGraceTimer:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:266: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD handleMinShowTimer:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:271: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD showUsingAnimation:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:279: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD hideUsingAnimation:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:307: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD done]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:324: error: 'isFinished' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD showWhileExecuting:onTarget:withObject:animated:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:337: error: 'methodForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:338: error: 'targetForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:339: error: 'objectForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD launchExecution]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:348: error: stray '@' in program
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:348: error: 'autoreleasepool' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:348: error: expected ';' before '{' token
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD cleanUp]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:364: error: 'targetForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:365: error: 'objectForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:367: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD setupLabels]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:373: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:383: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD layoutSubviews]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:446: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:456: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD updateUIForKeypath:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:587: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:591: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD setTransformForCurrentOrientation:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:646: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: At top level:
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:663: error: inconsistent instance variable specification
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView progress]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:668: error: '_progress' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:669: warning: control reaches end of non-void function
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView setProgress:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:672: error: '_progress' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView isAnnular]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:677: error: '_annular' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:678: warning: control reaches end of non-void function
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView setAnnular:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:681: error: '_annular' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView initWithFrame:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:696: error: '_progress' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:697: error: '_annular' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView drawRect:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:710: error: '_annular' undeclared (first use in this function)

/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:65: error: inconsistent instance variable specification
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD initWithFrame:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:179: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:179: error: (Each undeclared identifier is reported only once
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:179: error: for each function it appears in.)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD dealloc]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:208: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:209: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD show:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:223: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD hide:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:237: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD handleGraceTimer:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:266: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD handleMinShowTimer:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:271: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD showUsingAnimation:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:279: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD hideUsingAnimation:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:307: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD done]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:324: error: 'isFinished' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD showWhileExecuting:onTarget:withObject:animated:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:337: error: 'methodForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:338: error: 'targetForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:339: error: 'objectForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD launchExecution]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:348: error: stray '@' in program
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:348: error: 'autoreleasepool' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:348: error: expected ';' before '{' token
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD cleanUp]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:364: error: 'targetForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:365: error: 'objectForExecution' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:367: error: 'useAnimation' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD setupLabels]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:373: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:383: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD layoutSubviews]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:446: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:456: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD updateUIForKeypath:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:587: error: 'label' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:591: error: 'detailsLabel' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBProgressHUD setTransformForCurrentOrientation:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:646: error: 'rotationTransform' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: At top level:
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:663: error: inconsistent instance variable specification
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView progress]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:668: error: '_progress' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:669: warning: control reaches end of non-void function
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView setProgress:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:672: error: '_progress' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView isAnnular]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:677: error: '_annular' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:678: warning: control reaches end of non-void function
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView setAnnular:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:681: error: '_annular' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView initWithFrame:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:696: error: '_progress' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:697: error: '_annular' undeclared (first use in this function)
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m: In function '-[MBRoundProgressView drawRect:]':
/Users/xalapan/Documents/apps/yair/Classes/MBProgressHUD.m:710: error: '_annular' undeclared (first use in this function)

__weak references before blocks

I was watching a WWDC 2012 keynote and searched the web and Applee's documentation. Confer: http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

I'm not sure about it, to be honest. My proposal would be to change

- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue
     completionBlock:(MBProgressHUDCompletionBlock)completion {
    self.taskInProgress = YES;
    self.completionBlock = completion;
    dispatch_async(queue, ^(void) {
        block();
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            [self cleanUp];
        });
    });
  [self show:animated];
}

... into:

- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue
     completionBlock:(MBProgressHUDCompletionBlock)completion {
    self.taskInProgress = YES;
    self.completionBlock = completion;
    MBProgressHUD *__weak weakSelf = self;
    // MBProgressHUD *__unsafe_unretained weakSelf = self; // for iOS 4 target
    dispatch_async(queue, ^(void) {
        block();
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            [weakSelf cleanUp];
        });
    });
  [self show:animated];
}

What do you think?

Static Analyzer Warning

On line 243 in MBProgressHUD.m Apple's Static Analyzer wants this:

if (self = [super initWithFrame:frame])

to be

if ((self = [super initWithFrame:frame]))

It's kind of lame I know, but since I have warnings set to errors and run the static analyzer every time I build, I saw it right away.

Static function

Here is an extension I use to flash a quick error message:

extension MBProgressHUD {
    /// Briefly display an error message with a popover display
    static func flashError(error: NSError) {
        self.flashText(error.localizedDescription)
    }

    static func flashText(text: String) {
        let window = UIApplication.sharedApplication().keyWindow!
        MBProgressHUD.hideAllHUDsForView(window, animated: false)

        let hud = MBProgressHUD(view: window)
        hud.mode = .CustomView
        hud.removeFromSuperViewOnHide = true

        let view: UITextView = UITextView(frame: CGRectMake(0, 0, 200, 200))
        view.text = text
        view.font = hud.labelFont
        view.textColor = UIColor.whiteColor()
        view.backgroundColor = UIColor.clearColor()
        view.sizeToFit()

        hud.customView = view
        hud.show(true)
        hud.hide(true, afterDelay: 1.2)
    }
}

Perhaps something like this can be added upstream

No way to modify colour of text

There is no built in way to modify text colour. It's always forced to be white. Yet you can set the background colour. If you want a white/lightly coloured alert, you're out of luck.

Should be relatively easy fix to add in.

dimBackground doesn't rotate

Set dimBackground=Yes and rotate device: background will not get rotated (ProgressView does). Error also in the Demo-App.

I got around calling [self setTransformForCurrentOrientation:YES]; in the DeviceDidChageNotification for every case (remove if..) in MBProgressHUD.m and commented out the if/else part "if (UIInterfaceOrientationIsLandscape(orientation)) {..." in the setTransformForCurrentOrientation method.

But to be honest, I'm not really sure what I've done with this...

Could you please take a look?

Thanks for your work!
Regards
Gerd

Apple complains about show: hide: setLabelText:

Apple recently said:

 We have discovered one or more issues with your recent delivery. To process your delivery, the following issues must be corrected:
 Non-public API usage:
 The app references non-public selectors: hide:, setLabelText:, show:

Anyone else run into this? Does it make any sense to rename these methods to avoid Apple's warning?

Deprecated iOS 7 methods

There are 2 methods that are now deprecated due to iOS 7 UIKit changes.

CGSize labelSize = [label.text sizeWithFont:label.font];

and

CGSize detailsLabelSize = [detailsLabel.text sizeWithFont:detailsLabel.font 
                            constrainedToSize:maxSize lineBreakMode:detailsLabel.lineBreakMode];

crash when switching quickly between two uitableviews

I have a tab view controller app that switches between two tableviews. If I do this quickly I can get the HUD to crash as I have the HUD's showing up on both UITableviewcontrollers..

2010-08-02 22:44:43.116 Film Fest[962:8703] *** -[MBProgressHUD release]: message sent to deallocated instance 0x85490b0

Set position of hud

Hi,

How to set the position of hudview to the bottom, tried with yOffset but not working. (Swift)
hudView.yOffset = Float(self.view.center.y) + Float(100)

Crash on Rotation with iOS 4.2 GM

Hi the following line in - (void)deviceOrientationDidChange:(NSNotification *)notification method (MBProgressHUD.m line 595) causes a crash

self.frame = self.superview.bounds;

Not sure of the knock on effect, but testing that we still have a superview fixes it for me.

if (self.superview) {
self.frame = self.superview.bounds;
}

It could be something in the way I am calling HUD or maybe I'm over releasing. For the moment the changes works for me.

Zoom animation

The Zoom animation mode allows click-throughs before the HUD is completely hidden.

This is due to the fact that a transform is applied in order to scale the HUD. This transform scales the the HUD's invisible background and thereby allows touches to be received by views that are not covered anymore.

The best solution would probably be to separate the actual HUD from the invisible background (a new view) and do animations just on the HUD. This should also produce a better autoresizing behavior.

cornerRadius setting not in pod?

I can see in the code on github has a cornerRadius @Property, but when I install with pod 'MBProgressHUD' I seem to get an older version which does not have this property.

Unable to set label text

I have the following code in my app:

dispatch_async(dispatch_get_main_queue(), ^{ MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view]; hud.label.text = @"Authenticating"; [hud showAnimated:YES]; });

Which results in the following:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MBProgressHUD label]: unrecognized selector sent to instance 0x7fa0d33f00b0'

I recently upgraded to v1.0 and previously my code was re-using a single hud and would show/hide and update the label text appropriately. After updating to v1.0 I can't for the life of me get this to work. I've even tried changing the way I was accessing the reusable hud from self.hud to what you see in the above code snippet.

It seems the only way I can get the label text to work is to use the deprecated labelText approach.

when i use xcode8.0 runing ios8.4 app crash

if __IPHONE_OS_VERSION_MIN_REQUIRED < 90000

    appearance = [UIActivityIndicatorView appearanceWhenContainedIn:[MBProgressHUD class], nil];

else

    // For iOS 9+
    appearance = [UIActivityIndicatorView appearanceWhenContainedInInstancesOfClasses:@[[MBProgressHUD class]]];

endif

this code get the iphoneos version gte 900000, is 90300 so is go for ios 9+ .
then app crash .

why min required version is 90000

Different styles for determinate mode

I've made a little patch that allows different styles in determinate mode. The patch adds a new property and enumeration:

@Property (assign) MBDeterminateStyle determinateStyle;

The original/default style is MBDeterminateStyleRound, while the new style that I added is MBDeterminateStyleBar and uses a UIProgressBar behind the scenes.

The patch also updates the demo application so that you can see how this looks.

Fill color for pie chart in MBProgressHUDModeDeterminate

Hi,

I had been using the MBProgressHUD, marked as version 0.5 in the herder, that I got directly off of github last year, however it seems to differ from the cocoa pods 0.5 version.

I'm moving our project over to use cocoa pods and realized that you could no longer set the fill color for the pie chart and wanted to make sure I wan't missing something.

By setting the progressTintColor this is the result we had previously:
screen shot 2013-10-31 at 2 00 29 pm

Is this no longer supported?

Thanks

GCD compatibility?

I mostly use GCD for UI updates.

dispatch_async(dispatch_get_main_queue(), ^{
    // UI updates
});

But, your library checks using [NSThread isMainThread]. As GCD queues are not threads, my app often crashes. So I need to use selectors instead of calling blocks. Can we make this library GCD compatible?

Cancel button & background view selection

Hi, i want to use your library in my project, but i need a way to allow a cancel button to stop an action (for example during a long loading). Then, i noticed that if I use the hud to show only a text as a Toast in Android, I can't touch any view behind the hud and i have to wait until it hides.

targetForExecution prematurely released (race condition)

I do have a task that sometimes takes a lot of time while other times being done very fast. When the task (being executed by MBProgressHUD's launchExecution method) is finished, the targetForExecution object gets released in 'cleanUp'. Sometimes however, this causes serious problems as only afterwards (when the animation is finished), 'done' and thus 'performSelector' on the delegate is called. At this time, the delegate is of course (see above) released already...

Memory Leak

Memory leak discovered on MBProgressHUD.m.

Call to function 'CGGradientCreateWithColorComponents' returns a Core Foundation object with a +1 retain count (owning reference)
Object allocated on line 587 and stored into 'gradient' is not referenced later in this execution path and has a retain count of +1 (object leaked)

Window-generated View Not Full size in Landscape Orientation

When creating a HUD from a UIWindow object, if the device is in a landscape orientation, the view properly rotates, but its dimensions are not properly adjusted. If you rotate the device once the HUD is displayed, it will fill the screen. But if you're in landscape and just create it without rotating, it won't.

To really see it, add this line to -showOnWindow: in the demo project:

HUD.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];

Then launch the app, switch to landscape mode, and tap "On Window". You should see something like this:

MBProgressHUD UIWindow Bug

Which I think you'll agree isn't quite right. I can even interact with the view below on either side. :-(

Using stop animation for navigation controller

I've used this control on my app, but i got a strange situation. When user tap the cell, the app access a web service and then, navigate to another view controller (push). When user tap on back button, sometimes, instead of go back to previous viewcontroller animated, the screen blinks and go back.
So, i removed the MBProgressHUD and this nos occurs again.

What i'm doing wrong?

KVO crash workaround

Instead of KVO, can we use property getter & setters? Wouldn't this be an exact equivalent?

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.