热门标签 | 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;任何形式的转载都请联系作者获得授权并注明出处。

推荐阅读
  • 第六章:枚举类型与switch结构的应用分析
    第六章深入探讨了枚举类型与 `switch` 结构在编程中的应用。枚举类型(`enum`)是一种将一组相关常量组织在一起的数据类型,广泛存在于多种编程语言中。例如,在 Cocoa 框架中,处理文本对齐时常用 `NSTextAlignment` 枚举来表示不同的对齐方式。通过结合 `switch` 结构,可以更清晰、高效地实现基于枚举值的逻辑分支,提高代码的可读性和维护性。 ... [详细]
  • 在 Vue 应用开发中,页面状态管理和跨页面数据传递是常见需求。本文将详细介绍 Vue Router 提供的两种有效方式,帮助开发者高效地实现页面间的数据交互与状态同步,同时分享一些最佳实践和注意事项。 ... [详细]
  • 使用 Vuex 管理表单状态:当输入框失去焦点时自动恢复初始值 ... [详细]
  • NOIP2000的单词接龙问题与常见的成语接龙游戏有异曲同工之妙。题目要求在给定的一组单词中,从指定的起始字母开始,构建最长的“单词链”。每个单词在链中最多可出现两次。本文将详细解析该题目的解法,并分享学习过程中的心得体会。 ... [详细]
  • 本文详细探讨了使用纯JavaScript开发经典贪吃蛇游戏的技术细节和实现方法。通过具体的代码示例,深入解析了游戏逻辑、动画效果及用户交互的实现过程,为开发者提供了宝贵的参考和实践经验。 ... [详细]
  • 如何在C#中配置组合框的背景颜色? ... [详细]
  • 本文详细探讨了 jQuery 中 `ajaxSubmit` 方法的使用技巧及其应用场景。首先,介绍了如何正确引入必要的脚本文件,如 `jquery.form.js` 和 `jquery-1.8.0.min.js`。接着,通过具体示例展示了如何利用 `ajaxSubmit` 方法实现表单的异步提交,包括数据的发送、接收和处理。此外,还讨论了该方法在不同场景下的应用,如文件上传、表单验证和动态更新页面内容等,提供了丰富的代码示例和最佳实践建议。 ... [详细]
  • 在Android应用开发中,实现与MySQL数据库的连接是一项重要的技术任务。本文详细介绍了Android连接MySQL数据库的操作流程和技术要点。首先,Android平台提供了SQLiteOpenHelper类作为数据库辅助工具,用于创建或打开数据库。开发者可以通过继承并扩展该类,实现对数据库的初始化和版本管理。此外,文章还探讨了使用第三方库如Retrofit或Volley进行网络请求,以及如何通过JSON格式交换数据,确保与MySQL服务器的高效通信。 ... [详细]
  • 本指南从零开始介绍Scala编程语言的基础知识,重点讲解了Scala解释器REPL(读取-求值-打印-循环)的使用方法。REPL是Scala开发中的重要工具,能够帮助初学者快速理解和实践Scala的基本语法和特性。通过详细的示例和练习,读者将能够熟练掌握Scala的基础概念和编程技巧。 ... [详细]
  • 技术日志:使用 Ruby 爬虫抓取拉勾网职位数据并生成词云分析报告
    技术日志:使用 Ruby 爬虫抓取拉勾网职位数据并生成词云分析报告 ... [详细]
  • ButterKnife 是一款用于 Android 开发的注解库,主要用于简化视图和事件绑定。本文详细介绍了 ButterKnife 的基础用法,包括如何通过注解实现字段和方法的绑定,以及在实际项目中的应用示例。此外,文章还提到了截至 2016 年 4 月 29 日,ButterKnife 的最新版本为 8.0.1,为开发者提供了最新的功能和性能优化。 ... [详细]
  • 深入解析 Android 中 EditText 的 getLayoutParams 方法及其代码应用实例 ... [详细]
  • C++ 开发实战:实用技巧与经验分享
    C++ 开发实战:实用技巧与经验分享 ... [详细]
  • 本文全面解析了JavaScript中的DOM操作,并提供了详细的实践指南。DOM节点(Node)通常代表一个标签、文本或HTML属性,每个节点都具有一个nodeType属性,用于标识其类型。文章深入探讨了DOM节点的创建、查询、修改和删除等操作,结合实际案例,帮助读者更好地理解和掌握DOM编程技术。 ... [详细]
  • Objective-C 中的委托模式详解与应用 ... [详细]
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社区 版权所有