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

iOS两款你可能会用到的弹出框

前言好久没写博客了……最近拿到了一版原型图,各种弹框,简直快把老爷给弹死了……因为实现功能是其次的,最主要还得把这些东西给封装一下
前言

好久没写博客了……最近拿到了一版原型图,各种弹框,简直快把老爷给弹死了……因为实现功能是其次的,最主要还得把这些东西给封装一下,方便同事的调用。于是乎,我就开始了爬坑的过程。经过两天的耕耘,出了两款风格迥异的弹框,这里给大家分享一下。。。同时也祭奠一下,我老去的容颜……

效果图

底部PickerView弹框(这个东西还是蛮常见的)

view.gif

中间TextView弹框(这个东西真不常见,Alert支持的是单行输入,也就是textField)

vie.gif
底部PickerView弹框(LHEditPickerView)

首先生成了一个LHEditPickView这个就是大家看到的那个弹出框的实体view
代码如下:
LHEditPickView.h

#import @interface LHEditPickView : UIView/*** 背景图(半透明全屏)*/
@property (nonatomic,weak)UIView *blackBgView;/*** 下部弹出框的ToolBar*/
@property (nonatomic,weak)UIToolbar *toolBarView;/*** 弹出框主题背景*/
@property (nonatomic,weak)UIView *mainBgView;/*** 部门选择PickView*/
@property (nonatomic,weak)UIPickerView *pickerView;/*** 取消按钮*/@property (nonatomic,weak)UIButton *cancelBtn;/*** 确定按钮*/
@property (nonatomic,weak)UIButton *sureBtn;@property (nonatomic,strong)NSArray *data;@property (nonatomic,copy) void (^refreshUserInterface)(NSString *);@property (nonatomic,copy) void (^dropEditPickerView)();@end'

LHEditPickView.m

#import "LHEditPickView.h"&#64;interface LHEditPickView()<UIPickerViewDelegate,UIPickerViewDataSource>{
//按钮的宽度
CGFloat _btnWidth;
NSString *_result;
}&#64;end&#64;implementation LHEditPickView-(instancetype)initWithFrame:(CGRect)frame{
self&#61;[super initWithFrame:frame];
if(self){//主背景图UIView *mainBgView&#61;[[UIView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];self.mainBgView&#61;mainBgView;mainBgView.backgroundColor&#61;[UIColor whiteColor];[self addSubview:mainBgView];//ToolBarUIToolbar *toolView&#61;[[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height/6)];[toolView setBackgroundImage:[UIImage imageNamed:&#64;"daohangtiao"] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];self.toolBarView&#61;toolView;toolView.backgroundColor&#61;[UIColor blueColor];[mainBgView addSubview:toolView];//取消&#xff0c;确定按钮_btnWidth&#61;100.0;UIButton *cancelbtn&#61;[UIButton buttonWithType:UIButtonTypeCustom];cancelbtn.frame&#61;CGRectMake(0, 0, _btnWidth, CGRectGetHeight(toolView.frame));[cancelbtn setTitle:&#64;"取消" forState:UIControlStateNormal];[cancelbtn addTarget:self action:&#64;selector(onclickCancel:) forControlEvents:UIControlEventTouchUpInside];self.cancelBtn&#61;cancelbtn;[toolView addSubview:cancelbtn];_btnWidth&#61;100.0;UIButton *sureBtn&#61;[UIButton buttonWithType:UIButtonTypeCustom];sureBtn.frame&#61;CGRectMake(frame.size.width-_btnWidth, 0, _btnWidth, CGRectGetHeight(toolView.frame));[sureBtn setTitle:&#64;"确定" forState:UIControlStateNormal];self.sureBtn&#61;sureBtn;[self.sureBtn addTarget:self action:&#64;selector(onclickSure:) forControlEvents:UIControlEventTouchUpInside];[toolView addSubview:sureBtn];//UIPickerViewUIPickerView *picker&#61;[[UIPickerView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(toolView.frame), frame.size.width, (frame.size.height/6)*5)];self.pickerView&#61;picker;picker.showsSelectionIndicator&#61;YES;picker.delegate&#61;self;picker.dataSource&#61;self;[mainBgView addSubview:picker];}
return self;
}//设置data并且设设置_result的初始值
-(void)setData:(NSArray *)data{
if(_data!&#61;data){_data&#61;data;_result&#61;data[0];
}
//刷新所有元素
[self.pickerView reloadAllComponents];
}#pragma mark -ButtonClick-(void)onclickCancel:(id)sender{
if(self.dropEditPickerView){self.dropEditPickerView();
}
}//确定按钮,block传值
-(void)onclickSure:(id)sender{
if(self.refreshUserInterface){self.refreshUserInterface(_result);
}
if(self.dropEditPickerView){self.dropEditPickerView();
}
}#pragma mark -PickerViewDelegate
//有多少行
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return self.data.count;
}
//有多少列
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}//设置每一行的内容
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return self.data[row];
}//设置选中结果
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
_result&#61;self.data[row];
}&#64;end

由于本人习惯于代码布局&#xff0c;所以很low……呵呵哒
现在主体显示的部分已经有了&#xff0c;现在就该操心怎么将它显示出来了&#xff0c;于是我又创建了一个类——LHBottomPickerView&#xff08;显示LHEditPickView)废话不多说&#xff0c;上代码&#xff1a;
LHBottomPickerView.h

#import #import "LHEditPickView.h"
&#64;interface LHBottomPickerView : UIView
&#64;property (nonatomic,weak)UIView *grayBgView;
&#64;property (nonatomic,weak)LHEditPickView *editView;
&#64;property (nonatomic,weak)UIViewController *controller;
&#64;property (nonatomic,copy)void (^bottomResultPresent)(NSString *);
&#64;property (nonatomic,strong)UITapGestureRecognizer *recognizer;&#43;(instancetype)showWithController:(UIViewController *)controller andData:(NSArray *)data;
-(instancetype)initWithController:(UIViewController *)controller;&#43;(void)showEditPickerViewWithController:(UIViewController *)controller andData:(NSArray *)data andBlock:(void (^)(NSString *temp))bottomResultPresent;&#64;end

LHBottomPickerView.m

#import "LHBottomPickerView.h"
#import "AppDelegate.h"&#64;interface LHBottomPickerView()<UIGestureRecognizerDelegate>&#64;end&#64;implementation LHBottomPickerView-(instancetype)initWithController:(UIViewController *)controller{
self&#61;[super init];
if(self){//黑色半透明背景AppDelegate *app&#61;(AppDelegate *)[UIApplication sharedApplication].delegate;UIView *grayBgView&#61;[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];grayBgView.backgroundColor&#61;[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];[app.window.rootViewController.view addSubview:grayBgView];grayBgView.hidden&#61;YES;self.grayBgView&#61;grayBgView;//为grayBgView添加点击手势UITapGestureRecognizer *tapGestureRecognizer &#61; [[UITapGestureRecognizer alloc] init];tapGestureRecognizer.numberOfTapsRequired &#61; 1; // 设置单击几次才触发方法[self.grayBgView setUserInteractionEnabled:YES];tapGestureRecognizer.delegate&#61;self;[tapGestureRecognizer addTarget:self action:&#64;selector(popAndPushPickerView)]; // 添加点击手势的方法tapGestureRecognizer.cancelsTouchesInView &#61; NO;[self.grayBgView addGestureRecognizer:tapGestureRecognizer];self.recognizer&#61;tapGestureRecognizer;//LHEditPickerViewLHEditPickView *editView&#61;[[LHEditPickView alloc]initWithFrame:CGRectMake(0, controller.view.bounds.size.height, controller.view.bounds.size.width, controller.view.bounds.size.height/5*2)];self.editView&#61;editView;self.editView.refreshUserInterface&#61;^(NSString * result){if(self.bottomResultPresent){self.bottomResultPresent(result);}};self.editView.dropEditPickerView&#61;^(){[self popAndPushPickerView];};[self.grayBgView addSubview:editView];}
return self;
}&#43;(instancetype)showWithController:(UIViewController *)controller andData:(NSArray *)data{
LHBottomPickerView *bottom&#61;[[self alloc]initWithController:controller];
bottom.controller&#61;controller;
bottom.editView.data&#61;data;
[controller.view addSubview:bottom];
[bottom popAndPushPickerView];
return bottom;
}-(void)popAndPushPickerView{
if(self.grayBgView.hidden){[UIView animateWithDuration:0.5 animations:^{self.grayBgView.hidden&#61;NO;self.editView.frame&#61;CGRectMake(0, self.controller.view.bounds.size.height/5*3, self.controller.view.bounds.size.width, self.controller.view.bounds.size.height/5*2);}];[self.grayBgView setUserInteractionEnabled:YES];
}else{[UIView animateWithDuration:0.5 animations:^{self.editView.frame&#61;CGRectMake(0, self.controller.view.bounds.size.height, self.controller.view.bounds.size.width, self.controller.view.bounds.size.height/5*2);} completion:^(BOOL finished) {[UIView animateWithDuration:0.5 animations:^{self.grayBgView.hidden&#61;YES;}];}];}}-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if ( [touch.view isKindOfClass:[UIButton class]])
{return NO;
}
//由于LHEdiPickView中的toolView也受到了手势的影响&#xff0c;所以在这里将这这个ToolView屏蔽掉
if([touch.view isKindOfClass:[UIToolbar class]]){return NO;
}return YES;
}&#43;(void)showEditPickerViewWithController:(UIViewController *)controller andData:(NSArray *)data andBlock:(void (^)(NSString *temp))bottomResultPresent{
LHBottomPickerView *bottom&#61;[LHBottomPickerView showWithController:controller andData:data];
bottom.bottomResultPresent&#61;bottomResultPresent;
}&#64;end

下面就是最神奇的地方&#xff0c;调用竟然会如此简单&#xff0c;还是上代码&#xff1a;
ViewController.h

#import "ViewController.h"
#import "LHBottomPickerView.h"
&#64;interface ViewController ()
&#64;property (nonatomic,weak)UIView *grayBgView;
&#64;property (nonatomic,weak)LHEditPickView *editView;
&#64;property (nonatomic,weak)UILabel *label;
&#64;property (nonatomic,weak)UIButton *button;
&#64;end&#64;implementation ViewController- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button&#61;[UIButton buttonWithType:UIButtonTypeCustom];
button.frame&#61;CGRectMake(0, 0, 100, 100);
button.backgroundColor&#61;[UIColor redColor];
[self.view addSubview:button];
self.button&#61;button;
[button addTarget:self action:&#64;selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];}-(void)clickBtn{
//**看到没&#xff0c;就是这么简单**
[LHBottomPickerView showEditPickerViewWithController:self andData:&#64;[&#64;"早晨",&#64;"中午",&#64;"下午"] andBlock:^(NSString *temp) {[self.button setTitle:temp forState:UIControlStateNormal];
}];}&#64;end

总结一下知识点&#xff1a;

  • block使用&#xff1a;block属性、block参数、block传递、block回调
  • 手势冲突
弹出TextView弹框&#xff08;LHPopTextView&#xff09;

这个弹框&#xff0c;当时写的时候就想去用AlertController或者AlertView,但是发现alertView和AlertController自带的是一个TextField,并且还是单行的&#xff0c;显然满足不了我的需求&#xff0c;真心不想自己写这一部分东西&#xff0c;但是最后&#xff0c;还是重写吧&#xff0c;因为没有&#xff0c;所以得造。

  • 这个与上一个效果略有不同&#xff0c;就是那个灰色的遮盖&#xff0c;第一个是用了UIView然后添加了手势&#xff0c;但是添加手势以后&#xff0c;会出现手势冲突&#xff0c;所以这个我把背景遮盖给换成了一个UIButton&#xff0c;这样子省了不少的功夫。代码如下&#xff1a;

LHTopTextView.h(弹出框的视图)

#import &#64;interface LHTopTextView : UIView&#64;property (nonatomic,weak)UITextView *textView;
&#64;property (nonatomic,weak)UIButton *submitBtn;
&#64;property (nonatomic,weak)UIButton *cancelBtn;&#64;property (nonatomic,weak)UILabel *titleLabel;&#64;property (nonatomic,copy) void(^submitBlock)(NSString * text);
&#64;property (nonatomic,copy) void(^closeBlock)();&#64;end

LHTopTextView.m

#import "LHTopTextView.h"&#64;interface LHTopTextView()<UITextViewDelegate>{
CGFloat _space;
NSString *_text;
CGFloat _margin;
}
&#64;end&#64;implementation LHTopTextView-(instancetype)initWithFrame:(CGRect)frame{
self&#61;[super initWithFrame:frame];
if(self){//设置两个控件之间的间距_space&#61;10.0;//设置与边框的间距_margin&#61;15.0;//设置圆角self.layer.cornerRadius&#61;5;[self.layer setMasksToBounds:YES];//设置背景色self.backgroundColor&#61;[UIColor whiteColor];//驳回申诉UILabel *titleLabel&#61;[[UILabel alloc]initWithFrame:CGRectMake((frame.size.width-2*_margin)/3&#43;_margin, _margin,(frame.size.width-2*_margin)/3, (frame.size.height-_margin*2-_space)/7)];self.titleLabel&#61;titleLabel;[self addSubview:titleLabel];[titleLabel setFont:[UIFont systemFontOfSize:20]];titleLabel.textAlignment&#61;NSTextAlignmentCenter;[titleLabel setText:&#64;"驳回申诉"];//输入框UITextView *textView&#61;[[UITextView alloc]initWithFrame:CGRectMake(_margin, CGRectGetMaxY(titleLabel.frame)&#43;_space, frame.size.width-2*_margin, CGRectGetHeight(titleLabel.frame)*4)];textView.backgroundColor&#61;[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.739140070921986];self.textView&#61;textView;textView.font&#61;[UIFont systemFontOfSize:15];NSString *str&#61;&#64;"请您输入您对处理结果的评价&#xff0c;最多128个字";textView.textColor&#61;[UIColor whiteColor];textView.text&#61;str;textView.returnKeyType&#61;UIReturnKeyDone;textView.delegate&#61;self;[self addSubview:textView];//seperateLineUIView *lineView&#61;[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(textView.frame)&#43;_margin, frame.size.width, 1)];lineView.backgroundColor&#61;[UIColor grayColor];[self addSubview:lineView];//取消按钮UIButton *cancelBtn&#61;[UIButton buttonWithType:UIButtonTypeCustom];cancelBtn.frame&#61;CGRectMake(0, CGRectGetMaxY(lineView.frame), frame.size.width/2, CGRectGetHeight(titleLabel.frame)*2);[cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];[cancelBtn setTitle:&#64;"关闭" forState:UIControlStateNormal];self.cancelBtn&#61;cancelBtn;[cancelBtn addTarget:self action:&#64;selector(clickCancel:) forControlEvents:UIControlEventTouchUpInside];[self addSubview:cancelBtn];//按钮分隔线UIView *seperateLine&#61;[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(cancelBtn.frame), CGRectGetMinY(cancelBtn.frame), 1, CGRectGetHeight(cancelBtn.frame))];seperateLine.backgroundColor&#61;[UIColor grayColor];[self addSubview:seperateLine];//确定按钮UIButton *sureBtn&#61;[UIButton buttonWithType:UIButtonTypeCustom];sureBtn.frame&#61;CGRectMake(CGRectGetMaxX(seperateLine.frame), CGRectGetMinY(cancelBtn.frame), CGRectGetWidth(cancelBtn.frame), CGRectGetHeight(cancelBtn.frame));self.submitBtn&#61;sureBtn;[sureBtn setTitle:&#64;"提交" forState:UIControlStateNormal];[sureBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];[sureBtn addTarget:self action:&#64;selector(clickSubmit:) forControlEvents:UIControlEventTouchUpInside];[self addSubview:sureBtn];}
return self;
}-(void)textViewDidBeginEditing:(UITextView *)textView{
textView.textColor&#61;[UIColor blackColor];
textView.text&#61;nil;
}
/*** 通过代理方法去设置不能超过128个字&#xff0c;但是可编辑*/
#pragma mark -UITextViewDelegate
-(void)textViewDidChange:(UITextView *)textView{
if(textView.text.length>&#61;128){textView.text&#61;[textView.text substringToIndex:127];
}
}#pragma mark -return键弹回键盘
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text

{

if ([text isEqualToString:&#64;"\n"]) {[textView resignFirstResponder];return NO;}
return YES; }#pragma mark -处理确定点击事件-(void)clickSubmit:(id)sender{
if(self.textView.editable){[self.textView resignFirstResponder];
}
if(self.textView.text.length>0){if([self.textView.textColor isEqual:[UIColor redColor]]||[self.textView.textColor isEqual:[UIColor whiteColor]]){[self.textView becomeFirstResponder];}else{if(self.submitBlock){self.submitBlock(self.textView.text);}}
}else{self.textView.textColor&#61;[UIColor redColor];self.textView.text&#61;&#64;"您输入的内容不能为空&#xff0c;请您输入内容";
}
}#pragma mark -处理取消点击事件-(void)clickCancel:(id)sender{
if(self.closeBlock){self.closeBlock();
}
}&#64;end

LHEditTextView.h(显示弹出框和遮盖的视图)

#import &#64;interface LHEditTextView : UIView&#64;property (nonatomic,weak)UIButton *grayBgView;
&#64;property (nonatomic,copy)void (^requestDataBlock)(NSString *text);&#43;(instancetype)showWithController:(UIViewController *)controller;
&#43;(void)showWithController:(UIViewController *)controller andRequestDataBlock:(void(^)(NSString *))requestDataBlock;
&#64;end

LHEditTextView.m

#import "LHEditTextView.h"
#import "AppDelegate.h"
#import "LHTopTextView.h"&#64;interface LHEditTextView()<UIGestureRecognizerDelegate>&#64;property (nonatomic,weak)LHTopTextView *topTextView;
&#64;property (nonatomic,weak)UIViewController *controller;
&#64;end&#64;implementation LHEditTextView-(instancetype)initWithController:(UIViewController *)controller{
self&#61;[super init];
if(self){//黑色半透明背景AppDelegate *app&#61;(AppDelegate *)[UIApplication sharedApplication].delegate;UIButton *grayBgView&#61;[UIButton buttonWithType:UIButtonTypeCustom];grayBgView.frame&#61;[UIScreen mainScreen].bounds;grayBgView.backgroundColor&#61;[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];[app.window.rootViewController.view addSubview:grayBgView];grayBgView.hidden&#61;YES;self.grayBgView&#61;grayBgView;[grayBgView addTarget:self action:&#64;selector(popAndPushPickerView) forControlEvents:UIControlEventTouchUpInside];LHTopTextView *topTextView&#61;[[LHTopTextView alloc]initWithFrame:CGRectMake(15, controller.view.bounds.size.height/3, controller.view.bounds.size.width-30, controller.view.bounds.size.height/3)];self.topTextView&#61;topTextView;topTextView.submitBlock&#61;^(NSString *text){[self popAndPushPickerView];if(self.requestDataBlock){self.requestDataBlock(text);}};topTextView.closeBlock&#61;^(){[self popAndPushPickerView];};[self.grayBgView addSubview:topTextView];}
return self;
}&#43;(instancetype)showWithController:(UIViewController *)controller{
LHEditTextView *editTextView&#61;[[self alloc]initWithController:controller];
editTextView.controller&#61;controller;
[controller.view addSubview:editTextView];
[editTextView popAndPushPickerView];
return editTextView;
}&#43;(void)showWithController:(UIViewController *)controller andRequestDataBlock:(void(^)(NSString *text))requestDataBlock{
LHEditTextView *edit&#61;[LHEditTextView showWithController:controller];
edit.requestDataBlock&#61;requestDataBlock;
}-(void)popAndPushPickerView{
if(self.grayBgView.hidden){[UIView animateWithDuration:0.5 animations:^{self.grayBgView.hidden&#61;NO;self.topTextView.hidden&#61;NO;}];[self.grayBgView setUserInteractionEnabled:YES];
}else{[UIView animateWithDuration:0.5 animations:^{self.topTextView.hidden&#61;YES;} completion:^(BOOL finished) {[UIView animateWithDuration:0.5 animations:^{self.grayBgView.hidden&#61;YES;}];}];}}&#64;end

调用还是十分简单&#xff1a;ViewController.m

#import "ViewController.h"
#import "LHEditTextView.h"
&#64;interface ViewController ()&#64;end&#64;implementation ViewController- (void)viewDidLoad {
[super viewDidLoad];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[LHEditTextView showWithController:self andRequestDataBlock:^(NSString *text) {NSLog(&#64;"这里面去实现数据的回调");
}];
}- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}&#64;end

这是这两天写的小demo,其实有心的人会把这两个demo封装到一起的&#xff0c;这样子今后用这也方便。。。。降龙十八掌&#xff0c;打完收工&#xff01;
有想要demo的&#xff0c;可以加我QQ&#xff1a;635326856
最近我发现好多人问我要代码&#xff0c;但是我整天不开电脑&#xff0c;给你们说&#xff0c;第一种样式其实很简单&#xff0c;就是将上面的代码给复制下来生成对应名字的文件&#xff08;.h和.m文件&#xff09;就可以了。



作者&#xff1a;Peak_One
链接&#xff1a;https://www.jianshu.com/p/328789026dba
來源&#xff1a;简书
简书著作权归作者所有&#xff0c;任何形式的转载都请联系作者获得授权并注明出处。

推荐阅读
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 本文介绍了Java高并发程序设计中线程安全的概念与synchronized关键字的使用。通过一个计数器的例子,演示了多线程同时对变量进行累加操作时可能出现的问题。最终值会小于预期的原因是因为两个线程同时对变量进行写入时,其中一个线程的结果会覆盖另一个线程的结果。为了解决这个问题,可以使用synchronized关键字来保证线程安全。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • Nginx使用(server参数配置)
    本文介绍了Nginx的使用,重点讲解了server参数配置,包括端口号、主机名、根目录等内容。同时,还介绍了Nginx的反向代理功能。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 展开全部下面的代码是创建一个立方体Thisexamplescreatesanddisplaysasimplebox.#Thefirstlineloadstheinit_disp ... [详细]
  • 标题: ... [详细]
  • 本文介绍了iOS数据库Sqlite的SQL语句分类和常见约束关键字。SQL语句分为DDL、DML和DQL三种类型,其中DDL语句用于定义、删除和修改数据表,关键字包括create、drop和alter。常见约束关键字包括if not exists、if exists、primary key、autoincrement、not null和default。此外,还介绍了常见的数据库数据类型,包括integer、text和real。 ... [详细]
author-avatar
纸鸢漫天飞舞
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有