Skip to content

Commit

Permalink
Added explanation for updating the view from the view controller
Browse files Browse the repository at this point in the history
  • Loading branch information
MaherKSantina committed Jan 11, 2018
1 parent e1677d8 commit 892e502
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
Binary file modified .DS_Store
Binary file not shown.
10 changes: 3 additions & 7 deletions MSAutoView/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@
<rect key="frame" x="67" y="238" width="240" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="title" value="This is an overriden title"/>
<userDefinedRuntimeAttribute type="number" keyPath="price">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="details" value="This is an overriden details"/>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="listingView" destination="XKD-5Y-F7e" id="iTX-g0-re5"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
Expand Down
13 changes: 6 additions & 7 deletions MSAutoView/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ import UIKit

class ViewController: UIViewController {

@IBOutlet weak var listingView: ListingView!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
listingView.title = "Title from View Controller"
listingView.details = "Details from View Controller"
listingView.price = 40
listingView.updateView()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


}

22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,34 @@ class ListingView: MSAutoView {

![Image](https://user-images.githubusercontent.com/24646608/34811485-34100180-f6f5-11e7-9671-44705690d06b.png)

- You can also override the default values from the storyboard's attributes inspector for the view:
- You can also override the default values from the storyboard's attributes inspector for the view (**Make sure you don't set the attributes in the attribute inspector of the xib or they will override all other values**):

![Image](https://user-images.githubusercontent.com/24646608/34811582-a519fe26-f6f5-11e7-8d71-80bb77d8c55f.png)

This is the result:

![Image](https://user-images.githubusercontent.com/24646608/34811599-c514e92a-f6f5-11e7-9405-e85e7ced94d5.png)

- You can also create a reference for the view in the view controller's class and set its values:

```swift
class ViewController: UIViewController {

@IBOutlet weak var listingView: ListingView!

override func viewDidLoad() {
super.viewDidLoad()
listingView.title = "Title from View Controller"
listingView.details = "Details from View Controller"
listingView.price = 40
listingView.updateView()
}

}
```

![Image](https://user-images.githubusercontent.com/24646608/34811911-7f51df36-f6f7-11e7-9a48-fce96c59d195.png)

## Deployment

If you want to use the auto view in your own project just copy the AutoView Folder.
Expand Down

0 comments on commit 892e502

Please sign in to comment.