添加基本页面

This commit is contained in:
2025-10-29 14:28:57 +08:00
parent 045d5eaff8
commit 23317c9fd4
8 changed files with 146 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
//
// BaseCell.h
// keyBoard
//
// Common base cell with default selection style and hook for setup.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface BaseCell : UITableViewCell
/// Convenience reuse identifier based on class name
+ (NSString *)reuseId;
/// Override point to add subviews and constraints
- (void)setupUI;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,32 @@
//
// BaseCell.m
// keyBoard
//
#import "BaseCell.h"
@implementation BaseCell
+ (NSString *)reuseId {
return NSStringFromClass(self);
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self setupUI];
}
return self;
}
- (void)prepareForReuse {
[super prepareForReuse];
// Reset state if needed by subclasses
}
- (void)setupUI {
// Subclasses override to build UI
}
@end

View File

@@ -0,0 +1,17 @@
//
// BaseTableView.h
// keyBoard
//
// A lightweight UITableView subclass for common defaults.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface BaseTableView : UITableView
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,30 @@
//
// BaseTableView.m
// keyBoard
//
#import "BaseTableView.h"
@implementation BaseTableView
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
if (self = [super initWithFrame:frame style:style]) {
[self commonInit];
}
return self;
}
- (void)commonInit {
self.sectionHeaderTopPadding = 0;
self.backgroundColor = [UIColor whiteColor];
self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
// Disable estimates to avoid jumpy updates for simple lists; tweak per-screen if needed
self.estimatedRowHeight = 0;
self.estimatedSectionHeaderHeight = 0;
self.estimatedSectionFooterHeight = 0;
self.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
}
@end