Skip to content

Commit

Permalink
udpate en_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminlinux committed Apr 16, 2018
1 parent 02bfd7d commit 9006cc9
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 5 deletions.
147 changes: 147 additions & 0 deletions docs/iOS/IMUIInputView_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,150 @@ To use IMUIInputView only need two simple steps, or you can check out our sample
func finishRecordVideo(videoPath: String, durationTime: Double)
```



# IMUICustomInputView

from [0.10.0 Version] you can use ```IMUICustomInputView ``` to customize you inputView. ```IMUIInputView``` is basic in ```IMUICustomInputView```. You can use ```IMUICustomInputView``` to put anything into inputTextView's left/right/bottom position,and put anything into inputView's FeatureView. and it is easy used, just like ```UICollectionView``` or ```UITableView``` .You need implement ```IMUICustomInputViewDataSource``` and ```IMUICustomInputViewDelegate``` protocol.

### Usage:

**Setp one:** drag a view to your UIViewController (storyboard or xib), and adjust class to ```IMUICustomInputView```,and set customInput's delegate and dataSource.
**Setp two:** implement ```IMUICustomInputViewDataSource```

- return left/right/bottom inputBarItemListView's item number

```
func imuiInputView(_ inputBarItemListView: UICollectionView,
numberForItemAt position: IMUIInputViewItemPosition) -> Int
```

- retuen left/right/bottom inputBarItemListView's item size

```
func imuiInputView(_ inputBarItemListView: UICollectionView,
_ position: IMUIInputViewItemPosition,
sizeForIndex indexPath: IndexPath) -> CGSize
```

- return left/right/bottom inputBarItemListView's item cell

```
func imuiInputView(_ inputBarItemListView: UICollectionView,
_ position: IMUIInputViewItemPosition,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
```

- return featureView's cell

```
func imuiInputView(_ featureView: UICollectionView,
cellForItem indexPath: IndexPath) -> UICollectionViewCell
```

**Setp three:** implement ```IMUICustomInputViewDelegate```

- Tells the delegate when inputTextview text did change

```
optional func textDidChange(text: String)
```

- Tells the delegate when keyboard will show

```
optional func keyBoardWillShow(height: CGFloat, durationTime: Double)
```

### API:

##### register

- register ```UICollectionViewCell``` to specified position, The usage just like ```UICollectionView```. there are two register function:

```
// register cell with class
public func register(_ cellClass: AnyClass?, in position: IMUIInputViewItemPosition, forCellWithReuseIdentifier identifier: String) { }
// register cell with nib
public func register(_ nib: UINib?,in position: IMUIInputViewItemPosition, forCellWithReuseIdentifier identifier: String) { }
```

example:

```
customIntputView.self.register(
UINib(nibName: "IMUIFeatureListIconCell", bundle: bundle),
in: .bottom,
forCellWithReuseIdentifier: "IMUIFeatureListIconCell"
)
func imuiInputView(_ inputBarItemListView: UICollectionView,
_ position: IMUIInputViewItemPosition,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
switch position {
case .bottom:
let cell = inputBarItemListView.dequeueReusableCell(
withReuseIdentifier: cellIdentifier,
for: indexPath)
default:
break
}
}
```

- featureView also need to register ```UICollectionViewCell ``` to featureView, there are two register function:

```
// register cell with class
public func registerForFeatureView(_ cellClass: AnyClass?,
forCellWithReuseIdentifier identifier: String) { }
// register cell with nib
public func registerForFeatureView(_ nib: UINib?,
forCellWithReuseIdentifier identifier: String) { }
```

example:

```
customInputView.registerForFeatureView(
UINib(nibName: "IMUIRecordVoiceCell", bundle: bundle),
forCellWithReuseIdentifier: "IMUIRecordVoiceCell"
)
func imuiInputView(_ featureView: UICollectionView,
cellForItem indexPath: IndexPath) -> UICollectionViewCell {
let cell = featureView.dequeueReusableCell(
withReuseIdentifier: CellIdentifier,
for: indexPath
)
}
```

##### update inputView's item(inputBar' cell and FeatureView's cell)

Sometime you need to update inputView's item(ex: if textView's text is empty, you want to set send button's color to gray that mean the button is unable to click), You can use the following methods:

```
//update inputBar's item
public func updateInputBarItemCell(_ position: IMUIInputViewItemPosition,
at index: Int)
//update featureView's content,
public func reloadFeaturnView()
```

##### show featureView

```
customInputView.showFeatureView()
```

##### hidden featureView

```
customInputView.hideFeatureView()
```

5 changes: 0 additions & 5 deletions iOS/IMUIInputView/Controllers/IMUICustomInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ open class IMUICustomInputView: UIView {
}
}

func leaveGalleryMode() {
featureView.clearAllSelectedGallery()
// self.updateSendBtnToPhotoSendStatus()
}

@objc func keyboardFrameChanged(_ notification: Notification) {
let dic = NSDictionary(dictionary: (notification as NSNotification).userInfo!)
let keyboardValue = dic.object(forKey: UIKeyboardFrameEndUserInfoKey) as! NSValue
Expand Down

0 comments on commit 9006cc9

Please sign in to comment.