Skip to content

Commit

Permalink
fix possible crash
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed Oct 6, 2016
1 parent ec9a55c commit 89736b8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TBEmptyDataSet.xcworkspace/xcuserdata
4 changes: 2 additions & 2 deletions Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<string>2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>12</string>
<string>13</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
11 changes: 11 additions & 0 deletions TBEmptyDataSet/EmptyDataView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,22 @@ internal class EmptyDataView: UIView {
var views = [String: UIView]()

if shouldShowImageView() {
if imageView.superview == nil {
contentView.addSubview(imageView)
}
let viewString = ViewStrings.imageView
viewStrings.append(viewString)
views[viewString] = imageView

contentView.addConstraint(NSLayoutConstraint(item: imageView, attribute: .centerX, relatedBy: .equal, toItem: contentView, attribute: .centerX, multiplier: 1, constant: 0))
} else {
imageView.removeFromSuperview()
}

if shouldShowTitleLabel() {
if titleLabel.superview == nil {
contentView.addSubview(titleLabel)
}
let viewString = ViewStrings.titleLabel
viewStrings.append(viewString)
views[viewString] = titleLabel
Expand All @@ -166,6 +174,9 @@ internal class EmptyDataView: UIView {
}

if shouldShowDescriptionLabel() {
if descriptionLabel.superview == nil {
contentView.addSubview(descriptionLabel)
}
let viewString = ViewStrings.descriptionLabel
viewStrings.append(viewString)
views[viewString] = descriptionLabel
Expand Down
2 changes: 1 addition & 1 deletion TBEmptyDataSet/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<string>2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion TBEmptyDataSetExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = swiftlint;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
/* End PBXShellScriptBuildPhase section */

Expand Down

0 comments on commit 89736b8

Please sign in to comment.