用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/G1Joshi/Agent-Skills --skill uikit命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | uikit |
| description | UIKit imperative iOS UI framework. Use for iOS development. |
UIKit is the traditional, imperative framework for building iOS user interfaces. While SwiftUI is the future, UIKit remains essential for maintaining existing apps and unrestricted access to the OS.
// Programmatic UIKit (No Storyboards) in SceneDelegate
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = UINavigationController(rootViewController: HomeViewController())
window?.makeKeyAndVisible()
}
class HomeViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
title = "UIKit Home"
let button = UIButton(type: .system)
button.setTitle("Tap Me", for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
button.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}
}
Understanding viewDidLoad, viewWillAppear, viewDidLayoutSubviews is critical for managing state and layout updates correctly in the imperative model.
The layout engine based on constraints. Use NSLayoutConstraint or library wrappers (SnapKit) to define rules (e.g., "A is 10px below B").
Common pattern for handling events (UITableViewDelegate) and providing data (UITableViewDataSource).
Modern replacement for reloadData().
NSDiffableDataSourceSnapshot to animate changes automatically and safely.Modern API for building complex collection view layouts (grids, carousels) without subclassing UICollectionViewLayout.
Moving navigation logic out of ViewControllers to improve reusability and testing.
Do:
Don't:
layoutIfNeeded() unless animating changes.[weak self] in closures to avoid memory leaks (Retain Cycles).| Error | Cause | Solution |
|---|---|---|
Unsatisfiable Constraints | Conflicting Auto Layout rules. | Check console log for breaking constraint IDs; simplify rules. |
TableView Updates Crash | Inconsistent data vs rows. | Use Diffable Data Source or ensure data model updates before insertRows. |
Retain Cycle | Strong reference loop. | Use Memory Graph Debugger; verify [weak self]. |