mrackwitz / MRProgress

Collection of iOS drop-in components to visualize progress
MIT License
2.55k stars 305 forks source link

Sometimes not centered properly (too much at the bottom) #70

Closed Jeehut closed 9 years ago

Jeehut commented 9 years ago

Often the progress view isn't centered properly. See the following screenshot as an example:

img_2476

Jeehut commented 9 years ago

Another example: ios simulator screen shot 11 10 2014 11 37 31

mrackwitz commented 9 years ago

Hi @Dschee, thanks for reporting this behavior. I could reproduce that. This happens because MRProgressOverlayView doesn't override layoutSubviews and so is not relayouted correctly, after the containing view controller's view is resized. This was needed for proper animations.

You can circumvent this by showing the overlay not in viewDidLoad, but in viewWillAppear:animated:, which you should prefer anyway, because otherwise it will probably flicker through the resizing. If you are not showing the overlay in viewDidLoad as I guess, it would be helpful if you could explain where this happens in your code.

Jeehut commented 9 years ago

Thank you, @mrackwitz for that hint. You were right, I was using the progress view in viewDidLoad and moved it to viewWillAppear now. But I had this issue in many places within several projects and I don't currently have the time to check if they were all related to using it in viewDidLoad. Probably.

In any case I think it should be at least mentioned if not even seriously pointed towards within the "Usage" part of the Readme of this great project that one should not use it in viewDidLoad. That is a place I use very often to do work that only needs to be done once like loading additional data from the web that doesn't change too often.

mrackwitz commented 9 years ago

Generally you should never made any assumptions about view initialization in viewDidLoad. Either use viewDidAppear, if you need to do it once or viewDidLayoutSubviews, if you need to do it on layout changes. I see this more as a general iOS development question and not specific to the library. But thanks for the feedback. :wink:

Jeehut commented 9 years ago

Of course it is a general iOS development question where to do initialization. But viewDidLoad is a pre-created stub from XCode and the Apple documentation states this for viewDidLoad:

"You usually override this method to perform additional initialization on views that were loaded from nib files." – Apple documentation of UIViewController

So, I assume I'm not the only one who will naturally use it as a place for view initialization. But of course it is up to you how to deal with my feedback. :)