Esqarrouth/EZLoadingActivity

The view isn't in the centre when in a VC that is presented modally or is the master/detail

Sweeper777 opened this issue · 8 comments

I tried to present an EZLoadingActivity in a Form Sheet view controller and it is off centred. It appears at about the bottom left corner of the form sheet. It isn't centred either when it is in a master-detail view controller.

To reproduce, create a view controller A in the storyboard. Add a button that triggers a segue like this:

screen shot 2016-06-30 at 5 06 53 pm

screen shot 2016-06-30 at 5 07 14 pm

Connect the segue to view controller B.

In view controller B viewDidLoad, show the EZLoadingActivity.

I think this is due to showing the view in the window. Can you do something about it so that it always appears centered in the current view controller?

Have you done any experiments with this?

What could be changed to make this work? Because I don't normally use storyboards I don't have good ideas to fix this.

Which view is the superview of EZLoadindActivity? You should set the superview of EZLoadingActivity to be the current view controller's view

In that case when you are loading something, and the view changes behind, there are bugs and weird stuff happening. If you can catch them and fix them then feel free to send a pull request

I fixed it! Since I am quite new to github, I don't know how to create a Pull Request. I'll tell you where to change.

In EZLoadingActivity.swift line 108:

center = CGPoint(x: UIScreen.mainScreen().bounds.midX, y: UIScreen.mainScreen().bounds.midY)

Change the above line to

center = CGPoint(x: topMostController!.view.bounds.midX, y: topMostController!.view.bounds.midY)

And it should work on modally presented view controllers now. For the master detail views, I haven't found a solution yet.

I forgot to mention, the midX in the above code comes from the midX implementation in EZSwiftExtensions.

Oh, you just go inside the file and click edit, then click the big button at bottom to send a pull request.

Will this affect normal loading activities? Which aren't presented modally?

Just in case you didn't get the notification for pull requests.

Thanks 👍