Esqarrouth / EZLoadingActivity

:hatching_chick: Lightweight Swift loading activity for iOS7+
MIT License
608 stars 82 forks source link

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

Closed Sweeper777 closed 8 years ago

Sweeper777 commented 8 years ago

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?

Esqarrouth commented 8 years ago

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.

Sweeper777 commented 8 years ago

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

Esqarrouth commented 8 years ago

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

Sweeper777 commented 8 years ago

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.

Sweeper777 commented 8 years ago

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

Esqarrouth commented 8 years ago

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?

Sweeper777 commented 8 years ago

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

Esqarrouth commented 8 years ago

Thanks 👍