This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this takes a list of items in an array, then runs an observable on each of them, finally it combines | |
//all of the outputs into one observable which returns all of the media items at once | |
Observable.combineLatest(mediaItems.map({ $0.getMediaMetadataObservable() })).subscribe(onNext: { a in | |
for item in a { | |
print (item.type) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, heightForAnnotationAtIndexPath indexPath: IndexPath, withWidth width: CGFloat) -> CGFloat { | |
let x = dataSource?[indexPath] | |
let font = UIFont(name: "OpenSans", size: 11)! | |
let rect = NSString(string: x?.brief ?? "").boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil) | |
// if multiple types | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// force blinking the cursor | |
self!.inputTextField.inputView = UIView() | |
self!.inputTextField.becomeFirstResponder() | |
//re-enable for when user actually clicks | |
inputTextField.rx.controlEvent(.touchDown).subscribe(onNext: { [weak self] _ in | |
guard let _ = self else { return } | |
self!.inputTextField.inputView = nil | |
self!.inputTextField.reloadInputViews() | |
}).addDisposableTo(rx_disposeBag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// there are cases where you just need to update the display and not the data | |
// for example if you change the constants on a constraint | |
self!.tableView?.beginUpdates() | |
self!.tableView?.endUpdates() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let index = updates.index(where: {$0.id == self.prototypeUpdate?.id}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes for animation tutorial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ [weak self] (_) in | |
guard let _ = self else { return } | |
self!. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MAKE SURE YOU HAVE TOP TO BOTTOM CONSTRAINTS SET ON ALL OF THE OBJECTS IN THE HEADER VIEW!!! | |
// better as an extension | |
func sizeHeaderToFit() { | |
if let tableViewHeader = self.tableHeaderView { | |
let headerView = tableViewHeader | |
headerView.setNeedsLayout() | |
headerView.layoutIfNeeded() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//section model file | |
import RxDataSources | |
enum CommentTableSectionModel { | |
case section(comment: Comment, items: [CommentTableSectionModelItem]) | |
} | |
extension CommentTableSectionModel: SectionModelType { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
class func loadFromNibNamed(nibNamed: String, bundle : Bundle? = nil) -> UIView? { | |
return UINib( | |
nibName: nibNamed, | |
bundle: bundle | |
).instantiate(withOwner: nil, options: nil)[0] as? UIView | |
} | |
} |
NewerOlder