热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

iOS开发之实现一个APP界面框架

在上一篇博客中,给大家介绍了一下我们传统的APP界面框架—标签导航的一些优缺点,在这篇文章中我会来给大家演示,如何用代码去实现这一框架。本

在上一篇博客中,给大家介绍了一下我们传统的 APP 界面框架—标签导航的一些优缺点,在这篇文章中我会来给大家演示,如何用代码去实现这一框架。本次的实现我会分成俩部分来讲,好了闲话少说,接下来进入到开发阶段。

先来一张最终的效果图瞅一眼:

这里写图片描述

接下来,创建一个 Xcode 工程,我取名叫做CoolFrame,该项目我到时候会托管到 GitHub 上去维护,地址我会在下一篇博文中给出。

根据上图的样式,可以把界面分成三部分:导航栏,中间内容,以及底部的TabBar。我们先从简单的中间内容开始编码做起,这里我根据我底部有四个tabbar,所以定义了四个UIViewController,每个UIViewController很简单,主要是为了能够区分我下方点击的是哪一个TabBarItem,每个UIViewController中都用一个固定的英文字母显示在正中央,这里就列举其中一个界面的代码:

#import "FirstViewController.h"@interface FirstViewController ()@end@implementation FirstViewController
@synthesize label = _label;- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.self.title = @"A";[self.view setBackgroundColor:[UIColor whiteColor]];[[self label] setFrame:CGRectMake(roundf(self.view.frame.size.width - 100)/2, roundf(self.view.frame.size.height - 100)/2, 100, 100)];[self.label setTextAlignment:NSTextAlignmentCenter];[self.label setFont:[UIFont fontWithName:@"HiraKakuProN-W3" size:40.0f]];[self.label setText:@"A"];[self.view addSubview:[self label]];
}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}- (UILabel *)label{if(!_label){_label = [[UILabel alloc] init];}return _label;
}@end

中间部分很简单,接下来咱们来说说底部的 tabbar 是怎么实现的,先来看下效果图:

这里写图片描述

我来把效果图构造拆分成四个 UIButton 和一个 UIView ,这样是不是就很容易明白了,UIView 作为一个背景框里面填补了四个按钮,当我们选中其中一个按钮的时候中间就切换到对应的界面,随后按钮的背景色也随之改变。当然,在这里我们要实现的可以一个可以用作商业用途的框架,所以说我们这里的按钮就不可能是 Xcode 给我们提供的按钮,我们得需要自定义一个按钮,这样才能让我们的 UI 更加的美观,好了,这里附上按钮的代码:

//
// CustomTabBarItem.m
// CoolFrame
//
// Created by silicon on 2017/7/25.
// Copyright © 2017年 com.snailgames.coolframe. All rights reserved.
//#import "CustomTabBarItem.h"
#define RGB(r, g, b) [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:1.f]
@implementation CustomTabBarItem- (id)initWithFrame:(CGRect)frame{self = [super initWithFrame:frame];if(self){[self commonInitialization];}return self;
}- (id)init{return [self initWithFrame:CGRectZero];
}- (void)commonInitialization{[self setBackgroundColor:[UIColor clearColor]];_title = @"";_titlePositionAdjustment = UIOffsetZero;_unselectedTitleAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:10],NSForegroundColorAttributeName: RGB(0, 0, 0)};_selectedTitleAttributes = [_unselectedTitleAttributes copy];_badgeBackgroundColor = [UIColor redColor];_badgeTextColor = [UIColor whiteColor];_badgeTextFont = [UIFont systemFontOfSize:12];_badgePositionAdjustment = UIOffsetZero;
}- (void)drawRect:(CGRect)rect{CGSize frameSize = self.frame.size;CGSize titleSize = CGSizeZero;CGSize imageSize = CGSizeZero;NSDictionary *titleAttribute = nil;UIImage *backgroundimage = nil;UIImage *image = nil;CGFloat imageStartingY = 0.0f;if([self isSelected]){image = [self selectedImage];backgroundimage = [self selectedBackgroundImage];titleAttribute = [self selectedTitleAttributes];if(!titleAttribute){titleAttribute = [self unselectedTitleAttributes];}}else{image = [self unselectedImage];backgroundimage = [self unselectedBackgroundImage];titleAttribute = [self unselectedTitleAttributes];}imageSize = [image size];CGContextRef context = UIGraphicsGetCurrentContext();CGContextSaveGState(context);[backgroundimage drawInRect:self.bounds];if(!_title){[image drawInRect:CGRectMake(roundf(frameSize.width / 2 - imageSize.width / 2) +_imagePositionAdjustment.horizontal,roundf(frameSize.height / 2 - imageSize.height / 2) +_imagePositionAdjustment.vertical,imageSize.width, imageSize.height)];}else{titleSize = [_title boundingRectWithSize:CGSizeMake(frameSize.width, 20)options:NSStringDrawingUsesLineFragmentOriginattributes:@{NSFontAttributeName: titleAttribute[NSFontAttributeName]}context:nil].size;imageStartingY = roundf((frameSize.height - imageSize.height - titleSize.height) / 2);[image drawInRect:CGRectMake(roundf(frameSize.width / 2 - imageSize.width / 2) +_imagePositionAdjustment.horizontal,imageStartingY + _imagePositionAdjustment.vertical,imageSize.width, imageSize.height)];CGContextSetFillColorWithColor(context, [titleAttribute[NSForegroundColorAttributeName] CGColor]);[_title drawInRect:CGRectMake(roundf(frameSize.width / 2 - titleSize.width / 2) +_titlePositionAdjustment.horizontal,imageStartingY + imageSize.height + _titlePositionAdjustment.vertical,titleSize.width, titleSize.height)withAttributes:titleAttribute];}CGContextRestoreGState(context);
}#pragma mark - Image configuration- (UIImage *)finishedSelectedImage{return [self selectedImage];
}- (UIImage *)finishedUnselectedImage{return [self unselectedImage];
}- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage{if(selectedImage && selectedImage != [self selectedImage]){[self setSelectedImage:selectedImage];}if(unselectedImage && unselectedImage != [self unselectedImage]){[self setUnselectedImage:unselectedImage];}
}- (void)setBadgeValue:(NSString *)badgeValue{_badgeValue = badgeValue;[self setNeedsDisplay];
}#pragma mark - Background configuration- (UIImage *)backgroundSelectedImage{return [self backgroundSelectedImage];
}- (UIImage *)backgroundUnselectedImage{return [self backgroundUnselectedImage];
}- (void)setBackgroundSelectedImage:(UIImage *)selectedImage withUnselectedImage:(UIImage *)unselectedImage{if(selectedImage && selectedImage != [self selectedBackgroundImage]){[self setSelectedBackgroundImage:selectedImage];}if(unselectedImage && unselectedImage != [self unselectedBackgroundImage]){[self setUnselectedBackgroundImage:unselectedImage];}
}@end

搞定了按钮,接下来就要把按钮聚集在一起,所以需要写一个按钮容器视图,不管有多少个按钮都可以让他们在这个容器中和谐的铺展开来,并且在这个类中,还要为按钮添加必要的响应事件,容器视图也是作为一个子视图存在,所以我们这边就定义一个 UIView 即可,具体代码如下:

#import
#include "CustomTabBarItem.h"
@protocol CustomTabbarDelegate;@interface CustomTarbar : UIView
@property (nonatomic, strong) id delegate;
@property (nonatomic, strong) NSArray *items;
@property (nonatomic, strong) CustomTabBarItem *selectedItem;
@property (nonatomic, strong) UIView *backgroundView;
@property (nonatomic) CGFloat itemWidth;
@property (nonatomic) CGFloat miniContentHeight;@end@protocol CustomTabbarDelegate - (BOOL)tabBar:(CustomTarbar *)tabBar shouldSelectItemAtIndex:(NSInteger)index;
- (void)tabBar:(CustomTarbar *)tabBar didSelectItemAtIndex:(NSInteger)index;@end

//
// CustomTarbar.m
// CoolFrame
//
// Created by silicon on 2017/7/25.
// Copyright © 2017年 com.snailgames.coolframe. All rights reserved.
//#import "CustomTarbar.h"@implementation CustomTarbar
@synthesize delegate = _delegate;
@synthesize items = _items;
@synthesize selectedItem = _selectedItem;
@synthesize backgroundView = _backgroundView;
@synthesize miniContentHeight = _miniContentHeight;
@synthesize itemWidth = _itemWidth;- (id)initWithFrame:(CGRect)frame{self = [super initWithFrame:frame];if(self){[self commonInitlization];}return self;
}- (id)init{return [self initWithFrame:CGRectZero];
}- (void)commonInitlization{self.backgroundView = [[UIView alloc] init];[self addSubview:self.backgroundView];
}- (void)layoutSubviews{CGSize framesize = self.frame.size;CGFloat height = self.miniContentHeight;[self.backgroundView setFrame:CGRectMake(0, framesize.height - height, framesize.width, framesize.height)];[self setItemWidth:roundf(framesize.width / self.items.count)];int index = 0;for (CustomTabBarItem *item in [self items]) {CGFloat itemHeight = item.itemHeight;if(!itemHeight){itemHeight = framesize.height;}[item setFrame:CGRectMake(self.itemWidth * index, framesize.height - height, self.itemWidth, itemHeight)];[item setNeedsDisplay];index++;}
}#pragma mark - meathod
- (void)setItemWidth:(CGFloat)itemWidth{if(itemWidth > 0){_itemWidth = itemWidth;}
}- (void)setItems:(NSArray *)items{_items = items;for(CustomTabBarItem *item in items){[item addTarget:self action:@selector(tabBarItemWasSelected:) forControlEvents:UIControlEventTouchUpInside];[self addSubview:item];}
}- (CGFloat)miniContentHeight{CGFloat minimumConentHeight = CGRectGetHeight(self.frame);for (CustomTabBarItem *item in [self items]) {CGFloat height = [item itemHeight];if(height && height }#pragma mark -Item selection
- (void)tabBarItemWasSelected:(id)sender{if([[self delegate] respondsToSelector:@selector(tabBar:shouldSelectItemAtIndex:)]){NSInteger index = [self.items indexOfObject:sender];if(![[self delegate] tabBar:self shouldSelectItemAtIndex:index]){return;}}[self setSelectedItem:sender];if([[self delegate] respondsToSelector:@selector(tabBar:didSelectItemAtIndex:)]){NSInteger index = [self.items indexOfObject:self.selectedItem];[[self delegate] tabBar:self didSelectItemAtIndex:index];}
}- (void)setSelectedItem:(CustomTabBarItem *)selectedItem{if(selectedItem == _selectedItem){return;}[_selectedItem setSelected:NO];_selectedItem = selectedItem;[_selectedItem setSelected:YES];
}@end

到这里,我们的开发进度差不多已经完成了 50% ,但是我们的 App 还不能够顺利的运行起来,因为我们还缺一个视图控制类,我们前面开发完成了:主要内容界面,按钮以及存放按钮的容器,但这些类别都是单独存在的,我们需要一个组织者能够把他们串起来,这就要求我们还要再开发一个控制器类,那该如何下手呢!其实很简单,因为我们的按钮有自己的点击事件,只要能够告诉我们的控制器是哪个按钮点击了,那我们不就可以去切换那妞,控制去显示主界面了嘛!这里就要用到代理 Delegate 了( Ps: 你如果代码看的比较多,就会发现这个模式简直就是无处不再,太有用了), 触发按钮后通过代理,控制器类就会知道是哪一个按钮被点击了,很简单直接看代码:


#import
#import "CustomTarbar.h"@protocol CustomTarBarControllerDelegate;@interface CustomTabBarController : UIViewController
@property (nonatomic, strong) id delegate;
@property (nonatomic, strong) CustomTarbar *customTarbar;
@property (nonatomic, strong) NSMutableArray *viewControllers;
@property (nonatomic, strong) UIViewController *selectedViewController;
@property (nonatomic, strong) UIView *contentView;
@property (nonatomic) NSUInteger selectIndex;
@property (nonatomic) BOOL tabbarHidden;- (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated;@end@protocol CustomTarBarControllerDelegate
@optional
- (BOOL)tabBarController:(CustomTabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController;- (void)tabBarController:(CustomTabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;@end

//
// CustomTabBarController.m
// CoolFrame
//
// Created by silicon on 2017/7/25.
// Copyright © 2017年 com.snailgames.coolframe. All rights reserved.
//#import "CustomTabBarController.h"
#import @interface CustomTabBarController ()@end@implementation CustomTabBarController
@synthesize delegate = _delegate;
@synthesize viewControllers = _viewControllers;
@synthesize selectIndex = _selectIndex;
@synthesize contentView = _contentView;
@synthesize customTarbar = _customTarbar;- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.self.title = @"CoolFrame";[self.view addSubview:[self contentView]];[self.view addSubview:[self customTarbar]];}- (void)viewWillAppear:(BOOL)animated{[super viewWillAppear:animated];[self setSelectIndex:[self selectIndex]];[[self customTarbar] setSelectedItem:[[self.customTarbar items] objectAtIndex:0]];[self setTabBarHidden:NO animated:NO];
}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}#pragma -meathod- (void)setViewControllers:(NSMutableArray *)viewControllers{if(viewControllers && [viewControllers isKindOfClass:[NSMutableArray class]]){_viewControllers = viewControllers;NSMutableArray *tabBarItems = [[NSMutableArray alloc] init];for (UIViewController *viewController in viewControllers) {CustomTabBarItem *tabBarItem = [[CustomTabBarItem alloc] init];[tabBarItem setTitle:viewController.title];[tabBarItems addObject:tabBarItem];}[[self customTarbar] setItems:tabBarItems];}
}- (UIViewController *)selectedViewController{return [self.viewControllers objectAtIndex:self.selectIndex];
}- (void)setSelectIndex:(NSUInteger)selectIndex{if(selectIndex > [self.viewControllers count]){return;}_selectIndex = selectIndex;if(_selectedViewController){[_selectedViewController willMoveToParentViewController:nil];[_selectedViewController.view removeFromSuperview];[_selectedViewController removeFromParentViewController];}[self setSelectedViewController:[self.viewControllers objectAtIndex:_selectIndex]];[self addChildViewController:self.selectedViewController];[[self selectedViewController].view setFrame:self.contentView.bounds];[self.contentView addSubview:self.selectedViewController.view];[self.selectedViewController didMoveToParentViewController:self];
}- (UIView *)contentView{if(!_contentView){_contentView = [[UIView alloc] init];[_contentView setBackgroundColor:[UIColor whiteColor]];[_contentView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];}return _contentView;
}- (CustomTarbar *)customTarbar{if(!_customTarbar){_customTarbar = [[CustomTarbar alloc] init];[_customTarbar setBackgroundColor:[UIColor clearColor]];[_customTarbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];_customTarbar.delegate = self;}return _customTarbar;
}- (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated{_tabbarHidden = hidden;CGSize viewSize = self.view.frame.size;CGFloat tabBarHeight = 49.0f;CGFloat tabBarY = viewSize.height;if(!hidden){tabBarY = viewSize.height - tabBarHeight;[[self customTarbar] setFrame:CGRectMake(0, tabBarY, viewSize.width, tabBarHeight)];[[self contentView] setFrame:CGRectMake(0, 0, viewSize.width, viewSize.height - tabBarHeight)];}}- (void)setTabbarHidden:(BOOL)tabbarHidden{[self setTabBarHidden:tabbarHidden animated:NO];
}#pragma -CustomTabbarDelegate- (BOOL)tabBar:(CustomTarbar *)tabBar shouldSelectItemAtIndex:(NSInteger)index{if (index > [self viewControllers].count) {return NO;}if([[self delegate] respondsToSelector:@selector(tabBarController:shouldSelectViewController:)]){if(![[self delegate] tabBarController:self shouldSelectViewController:[self viewControllers][index]]){return NO;}}if([self selectedViewController] == [self viewControllers][index]){if([[self selectedViewController] isKindOfClass:[UINavigationController class]]){UINavigationController *selectController = (UINavigationController *)[self selectedViewController];if([selectController topViewController] != [selectController viewControllers][0]){[selectController popToRootViewControllerAnimated:YES];return NO;}}return NO;}return YES;
}- (void)tabBar:(CustomTarbar *)tabBar didSelectItemAtIndex:(NSInteger)index{if(index <0 || index >&#61; [self viewControllers].count){return;}[self setSelectIndex:index];
}&#64;end

到这里&#xff0c;还缺一个导航栏&#xff0c;缺了咋办&#xff0c;咱们来给他加上不就完事了嘛&#xff01;首先定义一个类继承自 UINavigationBar &#xff0c;这个类我用于控制导航栏的大小&#xff0c;再创建一个继承自UINavigationController 的类&#xff0c;控制我们的界面为竖屏&#xff0c;具体的代码如下&#xff1a;

#import "CustomNavBar.h"&#64;implementation CustomNavBar{CGSize _previousSize;
}/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {// Drawing code
}
*/- (CGSize)sizeThatFits:(CGSize)size{size &#61; [super sizeThatFits:size];if([UIApplication sharedApplication].statusBarHidden){size.height &#61; 64;}return size;
}- (void)layoutSubviews{[super layoutSubviews];if(CGSizeEqualToSize(self.bounds.size, _previousSize)){_previousSize &#61; self.bounds.size;[self.layer removeAllAnimations];[self.layer.sublayers makeObjectsPerformSelector:&#64;selector(removeAllAnimations)];}}&#64;end

#import "CustomNavigationController.h"&#64;implementation CustomNavigationController- (BOOL)shouldAutorotate{return YES;
}- (UIInterfaceOrientationMask)supportedInterfaceOrientations{return UIInterfaceOrientationMaskPortrait;
}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{return UIInterfaceOrientationPortrait;
}&#64;end

最后&#xff0c;把该需要的资源文件都导入到工程目录中来&#xff0c;在我们的AppDelegate 中设置好&#xff0c;AppDelegate 代码如下&#xff1a;

#import "AppDelegate.h"#import "CustomNavigationController.h"
#import "CustomNavBar.h"#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "FouthViewController.h"#define NQFONT(v) [UIFont fontWithName:&#64;"HiraKakuProN-W3" size:v]
#define RGB(r, g, b) [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:1.f]
&#64;interface AppDelegate ()&#64;property (nonatomic, strong) FirstViewController *firstViewController;
&#64;property (nonatomic, strong) SecondViewController *secondViewController;
&#64;property (nonatomic, strong) ThirdViewController *thirdViewController;
&#64;property (nonatomic, strong) FouthViewController *fouthViewController;
&#64;property (nonatomic, strong) CustomTabBarController *tabBarController;&#64;property (nonatomic, strong) CustomNavigationController *navController;&#64;end&#64;implementation AppDelegate- (void)setupViewControllers{if(!self.firstViewController){self.firstViewController &#61; [[FirstViewController alloc] init];}if(!self.secondViewController){self.secondViewController &#61; [[SecondViewController alloc] init];}if(!self.thirdViewController){self.thirdViewController &#61; [[ThirdViewController alloc] init];}if(!self.fouthViewController){self.fouthViewController &#61; [[FouthViewController alloc] init];}self.tabBarController &#61; [[CustomTabBarController alloc] init];NSMutableArray *viewsArray &#61; [[NSMutableArray alloc] initWithObjects:self.firstViewController,self.secondViewController,self.thirdViewController,self.fouthViewController, nil];[self.tabBarController setViewControllers:viewsArray];[self.tabBarController setSelectIndex:0];self.tabBarController.delegate &#61; self;[self customizeTabBarForController:_tabBarController];if(!_navController){_navController &#61; [[CustomNavigationController new] initWithNavigationBarClass:[CustomNavBar class] toolbarClass:[UIToolbar class]];[_navController pushViewController:_tabBarController animated:NO];}
}- (void)customizeTabBarForController:(CustomTabBarController *)tabBarController{UIImage *finishedImage &#61; [UIImage imageNamed:&#64;"tabbar_back_selected"];UIImage *unfinishedImage &#61; [UIImage imageNamed:&#64;"tabbar_back_normal"];NSArray *tabBarItemImages &#61; &#64;[&#64;"latest",&#64;"rank", &#64;"contest", &#64;"me"];NSArray *tabBarItemTitles &#61; &#64;[NSLocalizedString(&#64;"新闻", nil),NSLocalizedString(&#64;"直播", nil),NSLocalizedString(&#64;"发现", nil), NSLocalizedString(&#64;"我", nil)];NSInteger index &#61; 0;for (CustomTabBarItem *item in [[tabBarController customTarbar] items]){[item setBackgroundSelectedImage:finishedImage withUnselectedImage:unfinishedImage];UIImage *selectedimage &#61; [UIImage imageNamed:[tabBarItemImages objectAtIndex:index]];UIImage *unselectedimage &#61; [UIImage imageNamed:[tabBarItemImages objectAtIndex:index]];[item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];[item setTitle:[tabBarItemTitles objectAtIndex:index]];item.unselectedTitleAttributes&#61; &#64;{NSFontAttributeName: NQFONT(10), NSForegroundColorAttributeName: RGB(255, 255, 255),};item.selectedTitleAttributes &#61; &#64;{NSFontAttributeName: NQFONT(10), NSForegroundColorAttributeName: RGB(255, 255, 255),};index&#43;&#43;;}
}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// Override point for customization after application launch.self.window &#61; [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];[self.window setBackgroundColor:[UIColor whiteColor]];[self setupViewControllers];[self.window setRootViewController:_navController];[self.window makeKeyAndVisible];return YES;
}


到这里&#xff0c;我们的开发就算完成了&#xff0c;一个简单的 App 界面框架就诞生了&#xff0c;在接下来的几篇文章中&#xff0c;我会对其不断的完善&#xff0c;加上更多新的东西&#xff0c;让其成为一个真正意义上的 App。

好了。祝大家生活愉快。多多收获友谊和爱情。如果想获取更多的讯息&#xff0c;请扫描下方二维码关注我的微信公众号&#xff1a;

这里写图片描述


推荐阅读
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 在重复造轮子的情况下用ProxyServlet反向代理来减少工作量
    像不少公司内部不同团队都会自己研发自己工具产品,当各个产品逐渐成熟,到达了一定的发展瓶颈,同时每个产品都有着自己的入口,用户 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • 本文详细介绍了Spring的JdbcTemplate的使用方法,包括执行存储过程、存储函数的call()方法,执行任何SQL语句的execute()方法,单个更新和批量更新的update()和batchUpdate()方法,以及单查和列表查询的query()和queryForXXX()方法。提供了经过测试的API供使用。 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • 本文介绍了如何使用C#制作Java+Mysql+Tomcat环境安装程序,实现一键式安装。通过将JDK、Mysql、Tomcat三者制作成一个安装包,解决了客户在安装软件时的复杂配置和繁琐问题,便于管理软件版本和系统集成。具体步骤包括配置JDK环境变量和安装Mysql服务,其中使用了MySQL Server 5.5社区版和my.ini文件。安装方法为通过命令行将目录转到mysql的bin目录下,执行mysqld --install MySQL5命令。 ... [详细]
  • Imtryingtofigureoutawaytogeneratetorrentfilesfromabucket,usingtheAWSSDKforGo.我正 ... [详细]
  • Spring学习(4):Spring管理对象之间的关联关系
    本文是关于Spring学习的第四篇文章,讲述了Spring框架中管理对象之间的关联关系。文章介绍了MessageService类和MessagePrinter类的实现,并解释了它们之间的关联关系。通过学习本文,读者可以了解Spring框架中对象之间的关联关系的概念和实现方式。 ... [详细]
  • React项目中运用React技巧解决实际问题的总结
    本文总结了在React项目中如何运用React技巧解决一些实际问题,包括取消请求和页面卸载的关联,利用useEffect和AbortController等技术实现请求的取消。文章中的代码是简化后的例子,但思想是相通的。 ... [详细]
  • 本文介绍了在iOS开发中使用UITextField实现字符限制的方法,包括利用代理方法和使用BNTextField-Limit库的实现策略。通过这些方法,开发者可以方便地限制UITextField的字符个数和输入规则。 ... [详细]
  • IOS开发之短信发送与拨打电话的方法详解
    本文详细介绍了在IOS开发中实现短信发送和拨打电话的两种方式,一种是使用系统底层发送,虽然无法自定义短信内容和返回原应用,但是简单方便;另一种是使用第三方框架发送,需要导入MessageUI头文件,并遵守MFMessageComposeViewControllerDelegate协议,可以实现自定义短信内容和返回原应用的功能。 ... [详细]
  • 本文讨论了在ASP中创建RazorFunctions.cshtml文件时出现的问题,即ASP.global_asax不存在于命名空间ASP中。文章提供了解决该问题的代码示例,并详细解释了代码中涉及的关键概念,如HttpContext、Request和RouteData等。通过阅读本文,读者可以了解如何解决该问题并理解相关的ASP概念。 ... [详细]
author-avatar
心雨1006600
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有