From 23317c9fd4cfc977d185c5e54bdec3e320871673 Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Wed, 29 Oct 2025 14:28:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9F=BA=E6=9C=AC=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- keyBoard.xcodeproj/project.pbxproj | 12 +++++++ keyBoard/Class/Base/V/BaseCell.h | 23 +++++++++++++ keyBoard/Class/Base/V/BaseCell.m | 32 +++++++++++++++++++ keyBoard/Class/Base/V/BaseTableView.h | 17 ++++++++++ keyBoard/Class/Base/V/BaseTableView.m | 30 +++++++++++++++++ keyBoard/Class/Home/VC/HomeVC.m | 11 ++++++- keyBoard/Class/Main/VC/BaseTabBarController.m | 14 +++++++- keyBoard/Class/Me/VC/MyVC.m | 10 +++++- 8 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 keyBoard/Class/Base/V/BaseCell.h create mode 100644 keyBoard/Class/Base/V/BaseCell.m create mode 100644 keyBoard/Class/Base/V/BaseTableView.h create mode 100644 keyBoard/Class/Base/V/BaseTableView.m diff --git a/keyBoard.xcodeproj/project.pbxproj b/keyBoard.xcodeproj/project.pbxproj index eb5d972..7faef9b 100644 --- a/keyBoard.xcodeproj/project.pbxproj +++ b/keyBoard.xcodeproj/project.pbxproj @@ -29,6 +29,8 @@ 04FC95CC2EB1E780007BD342 /* BaseTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95CB2EB1E780007BD342 /* BaseTabBarController.m */; }; 04FC95CF2EB1E7A1007BD342 /* HomeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95CE2EB1E7A1007BD342 /* HomeVC.m */; }; 04FC95D22EB1E7AE007BD342 /* MyVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95D12EB1E7AE007BD342 /* MyVC.m */; }; + 04FC95D72EB1EA16007BD342 /* BaseTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95D62EB1EA16007BD342 /* BaseTableView.m */; }; + 04FC95D82EB1EA16007BD342 /* BaseCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95D42EB1EA16007BD342 /* BaseCell.m */; }; 7A36414DFDA5BEC9B7D2E318 /* Pods_CustomKeyboard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1092FB2B452F95B15D4263 /* Pods_CustomKeyboard.framework */; }; A1B2C3D42EB0A0A100000001 /* KBFunctionTagCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D32EB0A0A100000001 /* KBFunctionTagCell.m */; }; A1B2C3E22EB0C0A100000001 /* KBNetworkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3E12EB0C0A100000001 /* KBNetworkManager.m */; }; @@ -103,6 +105,10 @@ 04FC95CE2EB1E7A1007BD342 /* HomeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeVC.m; sourceTree = ""; }; 04FC95D02EB1E7AE007BD342 /* MyVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyVC.h; sourceTree = ""; }; 04FC95D12EB1E7AE007BD342 /* MyVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyVC.m; sourceTree = ""; }; + 04FC95D32EB1EA16007BD342 /* BaseCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseCell.h; sourceTree = ""; }; + 04FC95D42EB1EA16007BD342 /* BaseCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseCell.m; sourceTree = ""; }; + 04FC95D52EB1EA16007BD342 /* BaseTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseTableView.h; sourceTree = ""; }; + 04FC95D62EB1EA16007BD342 /* BaseTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseTableView.m; sourceTree = ""; }; 2C1092FB2B452F95B15D4263 /* Pods_CustomKeyboard.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CustomKeyboard.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 51FE7C4C42C2255B3C1C4128 /* Pods-keyBoard.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-keyBoard.release.xcconfig"; path = "Target Support Files/Pods-keyBoard/Pods-keyBoard.release.xcconfig"; sourceTree = ""; }; 727EC7532EAF848B00B36487 /* keyBoard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = keyBoard.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -332,6 +338,10 @@ 04FC95C42EB1E4AB007BD342 /* V */ = { isa = PBXGroup; children = ( + 04FC95D32EB1EA16007BD342 /* BaseCell.h */, + 04FC95D42EB1EA16007BD342 /* BaseCell.m */, + 04FC95D52EB1EA16007BD342 /* BaseTableView.h */, + 04FC95D62EB1EA16007BD342 /* BaseTableView.m */, ); path = V; sourceTree = ""; @@ -599,6 +609,8 @@ 04FC95D22EB1E7AE007BD342 /* MyVC.m in Sources */, 043FBCD22EAF97630036AFE1 /* KBPermissionViewController.m in Sources */, 04C6EABE2EAF86530089C901 /* AppDelegate.m in Sources */, + 04FC95D72EB1EA16007BD342 /* BaseTableView.m in Sources */, + 04FC95D82EB1EA16007BD342 /* BaseCell.m in Sources */, 04FC95C92EB1E4C9007BD342 /* BaseNavigationController.m in Sources */, 04FC95CF2EB1E7A1007BD342 /* HomeVC.m in Sources */, 04C6EABF2EAF86530089C901 /* main.m in Sources */, diff --git a/keyBoard/Class/Base/V/BaseCell.h b/keyBoard/Class/Base/V/BaseCell.h new file mode 100644 index 0000000..868d274 --- /dev/null +++ b/keyBoard/Class/Base/V/BaseCell.h @@ -0,0 +1,23 @@ +// +// BaseCell.h +// keyBoard +// +// Common base cell with default selection style and hook for setup. +// + +#import + +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 + diff --git a/keyBoard/Class/Base/V/BaseCell.m b/keyBoard/Class/Base/V/BaseCell.m new file mode 100644 index 0000000..f13ec2e --- /dev/null +++ b/keyBoard/Class/Base/V/BaseCell.m @@ -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 + diff --git a/keyBoard/Class/Base/V/BaseTableView.h b/keyBoard/Class/Base/V/BaseTableView.h new file mode 100644 index 0000000..4704fff --- /dev/null +++ b/keyBoard/Class/Base/V/BaseTableView.h @@ -0,0 +1,17 @@ +// +// BaseTableView.h +// keyBoard +// +// A lightweight UITableView subclass for common defaults. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface BaseTableView : UITableView + +@end + +NS_ASSUME_NONNULL_END + diff --git a/keyBoard/Class/Base/V/BaseTableView.m b/keyBoard/Class/Base/V/BaseTableView.m new file mode 100644 index 0000000..2d8c519 --- /dev/null +++ b/keyBoard/Class/Base/V/BaseTableView.m @@ -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 + diff --git a/keyBoard/Class/Home/VC/HomeVC.m b/keyBoard/Class/Home/VC/HomeVC.m index 639fa80..c9319e5 100644 --- a/keyBoard/Class/Home/VC/HomeVC.m +++ b/keyBoard/Class/Home/VC/HomeVC.m @@ -15,7 +15,16 @@ - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view. + self.view.backgroundColor = [UIColor whiteColor]; + // Simple demo content so the tab is distinguishable + UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; + label.text = @"Home"; + label.textColor = [UIColor darkTextColor]; + label.font = [UIFont systemFontOfSize:20 weight:UIFontWeightSemibold]; + [label sizeToFit]; + label.center = self.view.center; + label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + [self.view addSubview:label]; } /* diff --git a/keyBoard/Class/Main/VC/BaseTabBarController.m b/keyBoard/Class/Main/VC/BaseTabBarController.m index fa3f39f..dd37e9d 100644 --- a/keyBoard/Class/Main/VC/BaseTabBarController.m +++ b/keyBoard/Class/Main/VC/BaseTabBarController.m @@ -8,6 +8,7 @@ #import "BaseTabBarController.h" #import "HomeVC.h" #import "MyVC.h" +#import "BaseNavigationController.h" @interface BaseTabBarController () @@ -17,7 +18,18 @@ - (void)viewDidLoad { [super viewDidLoad]; - + // Setup two tabs: Home & My, each embedded in BaseNavigationController + HomeVC *home = [[HomeVC alloc] init]; + home.title = @"首页"; + BaseNavigationController *navHome = [[BaseNavigationController alloc] initWithRootViewController:home]; + navHome.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:nil selectedImage:nil]; + + MyVC *my = [[MyVC alloc] init]; + my.title = @"我的"; + BaseNavigationController *navMy = [[BaseNavigationController alloc] initWithRootViewController:my]; + navMy.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:nil selectedImage:nil]; + + self.viewControllers = @[navHome, navMy]; } /* diff --git a/keyBoard/Class/Me/VC/MyVC.m b/keyBoard/Class/Me/VC/MyVC.m index 1fd7b2f..c142e01 100644 --- a/keyBoard/Class/Me/VC/MyVC.m +++ b/keyBoard/Class/Me/VC/MyVC.m @@ -15,7 +15,15 @@ - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view. + self.view.backgroundColor = [UIColor whiteColor]; + UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; + label.text = @"My"; + label.textColor = [UIColor darkTextColor]; + label.font = [UIFont systemFontOfSize:20 weight:UIFontWeightSemibold]; + [label sizeToFit]; + label.center = self.view.center; + label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + [self.view addSubview:label]; } /*