Skip to content

Commit e4574b5

Browse files
committed
Merge pull request #14 from hons82/master
Separate instantiation from showing the view. Otherwise it can happen…
2 parents d6f1839 + 459f6cc commit e4574b5

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

EZLoadingActivity.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "EZLoadingActivity"
3-
s.version = "0.7"
3+
s.version = "0.8"
44
s.summary = "Lightweight Swift loading activity for iOS7+"
55
s.description = "Lightweight Swift loading activity for iOS7+. Really simple to use, just add the class and write 1 line of code."
66
s.homepage = "https://github.com/goktugyil/EZLoadingActivity"

EZLoadingActivity.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ public struct EZLoadingActivity {
5050
print("EZLoadingActivity Error: You don't have any views set. You may be calling them in viewDidLoad. Try viewDidAppear instead.")
5151
return false
5252
}
53-
53+
// Separate creation from showing
54+
instance = LoadingActivity(text: text, disableUI: disableUI)
5455
dispatch_async(dispatch_get_main_queue()) {
55-
instance = LoadingActivity(text: text, disableUI: disableUI)
56+
instance?.showLoadingActivity()
5657
}
5758
return true
5859
}
@@ -126,17 +127,19 @@ public struct EZLoadingActivity {
126127
textLabel.textAlignment = NSTextAlignment.Center
127128
textLabel.text = text
128129

129-
addSubview(activityView)
130-
addSubview(textLabel)
131-
132-
topMostController!.view.addSubview(self)
133-
134130
if disableUI {
135131
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
136132
UIDisabled = true
137133
}
138134
}
139135

136+
func showLoadingActivity() {
137+
addSubview(activityView)
138+
addSubview(textLabel)
139+
140+
topMostController!.view.addSubview(self)
141+
}
142+
140143
func createShadow() {
141144
layer.shadowPath = createShadowPath().CGPath
142145
layer.masksToBounds = false

0 commit comments

Comments
 (0)