SplittableViewKit
A cell of IndexPath(row: 0, section: 0) in UITableView is automatically moved to left view when device rotated.
Install / Use
/learn @marty-suzuki/SplittableViewKitREADME
SplittableViewKit
A cell of IndexPath(row: 0, section: 0) in UITableView is automatically moved to left view when device rotated.

Usage
Please initialize SplittableTableView with initializer or Interface Builder.
SplittableTableView.rightView is UITableView.
Do not set delegate or dataSource directly to SplittableTableView.rightView.
You must use SplittableTableView.delgate or SplittableTableView.dataSource.
let splittableTableView: SplittableTableView
splittableTableView.delegate = self
splittableTableView.dataSource = self
splittableTableView.rightView.register(UINib(nibName: "ThumbnailViewCell", bundle: nil),
forCellReuseIdentifier: "ThumbnailViewCell")
SplittableViewKit is almost same as UITableView interface because SplittableTableViewDataSource adopted UITableViewDataSource and SplittableTableViewDelegate adopted UITableViewDelegate.
func splittableContainerViewFor(topView: UIView, layoutType: LayoutType) -> UIView is only one difference.
You should return a UIView that layouted top view. Layout patterns are LayoutType.left and LayoutType.fixedTop.
extension ViewController: SplittableTableViewDataSource {
func splittableContainerViewFor(topView: UIView, layoutType: LayoutType) -> UIView {
let view = UIView(frame: .zero)
topView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(topView)
if layoutType == .left {
NSLayoutConstraint.activate([
view.leadingAnchor.constraint(equalTo: topView.leadingAnchor, constant: 0),
view.trailingAnchor.constraint(equalTo: topView.trailingAnchor, constant: 0),
view.centerYAnchor.constraint(equalTo: topView.centerYAnchor, constant: 0)
])
} else {
NSLayoutConstraint.activate([
view.safeAreaLayoutGuide.topAnchor.constraint(equalTo: topView.topAnchor, constant: 0),
view.leftAnchor.constraint(equalTo: topView.leftAnchor, constant: 0),
view.rightAnchor.constraint(equalTo: topView.rightAnchor, constant: 0),
view.bottomAnchor.constraint(equalTo: topView.bottomAnchor, constant: 0)
])
}
return view
}
}
You can change fixed top or not with SplittableTableView.isFixedTop.
splittableTableView.isFixedTop = true
| left | fixedTop |
| :-: | :-: |
|
|
|
You can change ratio of leftView and rightView with SplittableTableView.ratio.
splittableTableView.ratio = .init(left: 1, right: 2)
| left: 1, right: 1 | left: 2, right: 1 |
| :-: | :-: |
|
|
|
Example
To run the example project, clone the repo, and run pod install from the SplittableViewKitExample directory first.
Requirements
- iOS 9 or greater
- Swift 4 or greater
Installation
Carthage
If you’re using Carthage, simply add SplittableViewKit to your Cartfile:
github "marty-suzuki/SplittableViewKit"
CocoaPods
SplittableViewKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SplittableViewKit'
Author
marty-suzuki, s1180183@gmail.com
License
SplittableViewKit is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
