日期选择和输入弹框

#import "EHExaminationPlanVC.h"

@interface EHExaminationPlanVC ()<UIGestureRecognizerDelegate, UIAlertViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *mTableView;

@property (nonatomic, strong) NSArray *titleArray;

@property (nonatomic, strong) NSArray *detailTextArray;

@property (nonatomic, strong) UIDatePicker *mDatePicker; // 日期选择控件

@property (nonatomic, strong) UIView *mDateView;

@property (nonatomic, strong) UIAlertView *alert;

@end

@implementation EHExaminationPlanVC

- (UIView *)mDateView

{

if (!_mDateView) {

_mDateView = [[UIView alloc] initWithFrame:CGRectMake(0, Main_Screen_Height - 240, Main_Screen_Width, 240)];

UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Main_Screen_Width, 40)];

topView.backgroundColor = [UIColor whiteColor];

[_mDateView addSubview:topView];

UIButton *cancelButton = [toolset createButtonWithText:@"取消"

withType:UIButtonTypeCustom

withFrame:CGRectMake(1, 0, 60, 40)

withFont:SYSTEMFONT(14)

withNormalColor:[UIColor blueColor]

withHightColor:[UIColor grayColor]

withBackgroundColor:nil

withDelegate:self

withSelector:@selector(buttonClick:)

withNormaleImage:nil

withLightImage:nil];

cancelButton.tag = 200;

[topView addSubview:cancelButton];

UIButton *OKButton = [toolset createButtonWithText:@"确认"

withType:UIButtonTypeCustom

withFrame:CGRectMake(Main_Screen_Width - 60, 0, 60, 40)

withFont:SYSTEMFONT(14)

withNormalColor:[UIColor blueColor]

withHightColor:[UIColor grayColor]

withBackgroundColor:nil

withDelegate:self

withSelector:@selector(buttonClick:)

withNormaleImage:nil

withLightImage:nil];

OKButton.tag = 201;

[topView addSubview:OKButton];

UIView *topSeparateView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Main_Screen_Width, 1)];

topSeparateView.backgroundColor = kColorAlpha(216, 216, 216, 1);

[topView addSubview:topSeparateView];

UIView *bottomSeparateView = [[UIView alloc] initWithFrame:CGRectMake(0, 39, Main_Screen_Width, 1)];

bottomSeparateView.backgroundColor = kColorAlpha(216, 216, 216, 1);

[topView addSubview:bottomSeparateView];

_mDatePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, Main_Screen_Width, 200)];

_mDatePicker.datePickerMode = UIDatePickerModeDate;

_mDatePicker.backgroundColor = [UIColor whiteColor];

_mDatePicker.hidden = NO;

[_mDateView addSubview:_mDatePicker];

UIApplication *app = [UIApplication sharedApplication];

[app.keyWindow  addSubview:_mDateView];

}

return _mDateView;

}

- (NSArray *)detailTextArray

{

if (!_detailTextArray) {

_detailTextArray = [self detailTextArrayData];

}

return _detailTextArray;

}

- (NSArray *)detailTextArrayData

{

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSString *timeStr = [defaults stringForKey:TestTime];

if (!timeStr)

timeStr = @"点击设置";

NSString *testResultStr = [defaults stringForKey:TestExpectedResults];

if (!testResultStr)

testResultStr = @"点击设置";

//    else

//    {

//        if ([testResultStr intValue] > 100)

//            testResultStr = @"100";

//    }

NSString *testCityStr = [defaults stringForKey:TestCity];

if (!testCityStr)

testCityStr = @"待定";

return [NSArray arrayWithObjects:timeStr, testResultStr, testCityStr, nil];

}

- (NSArray *)titleArray

{

if (!_titleArray) {

_titleArray = [NSArray arrayWithObjects:@"考试时间", @"期望成绩", @"考场城市", nil];

}

return _titleArray;

}

- (void)viewDidLoad {

[super viewDidLoad];

self.title = @"考试计划";

//    self.mTableView.backgroundColor = [UIColor whiteColor];

self.mTableView.tableFooterView = [[UIView alloc] init];

// 创建点击手势

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hiddenView:)];

[recognizer setNumberOfTapsRequired:1];

[recognizer setNumberOfTouchesRequired:1];

recognizer.delegate = self;

[self.mTableView addGestureRecognizer:recognizer];

}

- (void)viewWillDisappear:(BOOL)animated

{

[super viewWillDisappear:animated];

self.mDateView.hidden = YES;

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

#pragma mark ------  tableView数据源方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return 3;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

return 60.0;

}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

return 30;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *identifier = @"cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

if (!cell) {

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];

if (indexPath.row == 2)

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

else

cell.accessoryType = UITableViewCellAccessoryNone;

}

cell.textLabel.text = self.titleArray[indexPath.row];

cell.detailTextLabel.text = self.detailTextArray[indexPath.row];

cell.detailTextLabel.textColor = [UIColor blueColor];

return cell;

}

#pragma mark  ------  tableView代理方法

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

[tableView deselectRowAtIndexPath:indexPath animated:YES];

switch (indexPath.row) {

case 0:

{

self.mDateView.hidden = NO;

}

break;

case 1:

{

[self modifyTheDesiredResults];

self.mDateView.hidden = YES;

}

break;

case 2:

{

self.mDateView.hidden = YES;

}

break;

default:

break;

}

}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

{

UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Main_Screen_Width, 30)];

NSLog(@"%@", NSStringFromCGRect(tableView.tableHeaderView.bounds));

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 200, 30)];

titleLabel.text = @"托福考试计划";

titleLabel.textColor = [UIColor grayColor];

titleLabel.font = SYSTEMFONT(14);

[header addSubview:titleLabel];

return header;

}

#pragma mark 日期选择取消和确定

- (void)buttonClick:(UIButton *)button

{

switch (button.tag) {

case 200:

self.mDateView.hidden = YES;

break;

case 201:

{

NSDate *date = [self.mDatePicker date];

NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];

[dateformatter setDateFormat:@"yyyy年MM月dd日"];

NSString *dateStr = [dateformatter stringFromDate:date];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

[defaults setObject:dateStr forKey:TestTime];

[defaults synchronize];

self.detailTextArray = [self detailTextArrayData];

[self.mTableView reloadData];

self.mDateView.hidden = YES;

}

break;

default:

break;

}

}

- (void)hiddenView:(UIGestureRecognizer *)recognizer

{

self.mDateView.hidden = YES;

}

#pragma maek 修改期望的成绩

- (void)modifyTheDesiredResults

{

self.alert = [[UIAlertView alloc] initWithTitle:@"" message:@"期望成绩" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"修改", nil];

self.alert.alertViewStyle = UIAlertViewStylePlainTextInput;

[[self.alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeNumberPad];

self.alert.delegate = self;

[self.alert show];

UITapGestureRecognizer *recognizerTap = [[UITapGestureRecognizer alloc] initWithTarget:self

action:@selector(handleTapBehind:)];

[recognizerTap setNumberOfTapsRequired:1];

recognizerTap.cancelsTouchesInView = NO;

[[UIApplication sharedApplication].keyWindow addGestureRecognizer:recognizerTap];

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

switch (buttonIndex) {

case 0:

break;

case 1:

{

//得到输入框

UITextField *textField = [alertView textFieldAtIndex:0];

NSLog(@"%@", textField.text);

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

[defaults setObject:textField.text forKey:TestExpectedResults];

[defaults synchronize];

self.detailTextArray = [self detailTextArrayData];

[self.mTableView reloadData];

} break;

default:

break;

}

}

#pragma mark 点击外包区域隐藏alertView

- (void)handleTapBehind:(UITapGestureRecognizer *)sender{

if (sender.state == UIGestureRecognizerStateEnded){

CGPoint location = [sender locationInView:nil];

if (![self.alert pointInside:[self.alert convertPoint:location fromView:self.alert.window] withEvent:nil]){

[self.alert.window removeGestureRecognizer:sender];

[self.alert dismissWithClickedButtonIndex:0

animated:YES];

}

}

}

// 手势冲突

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

{

if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {

return NO;

}

return YES;

}

@end

时间: 2024-10-29 03:48:56

日期选择和输入弹框的相关文章

活动已结束,日期时间比较并弹框跳转

var now = new Date(), end = new Date("2014/12/16 10:00"); if(now > end){ var html = '<div id="mbox_overlay" class="mbox_overlay"></div>'+ '<div class="pop-box">'+ '<p>很遗憾,活动已经结束啦</p>

Axure 万年历(日期选择下拉文本框)

百度网盘:http://pan.baidu.com/s/1c1ZjUPq 点击“图1”可呈现出“图2”的效果.(已实现模板化功能,不用去研究去为什么,直接使用即可)

iOS 可高度自定义的底部弹框

技术: iOS Objective-C 概述 一个可以让开发者通过编写 tableView 的内容随心所欲的定制自己想要的底部弹框 详细 代码下载:http://www.demodashi.com/demo/14901.html 一. 运行效果图 二. 实现过程 1. 实现一个有遮罩效果的半透明 view,然后添加一个可设置展示内容高度的 contentView // 这个遮罩是可以遮住全屏 - (void)createUI{ self.frame = CGRectMake(0, 0, SS_S

Easyui datebox单击文本框显示日期选择

Easyui默认是点击文本框后面的图标显示日期,为了更进一步优化体验 修改为单击文本框显示日期选择框 修改jquery.easyui.min.js(作者用的是1.3.6版本,其他版本或有区别) 可 ctrl+f 搜索 "_outerWidth():0" 在本行下面添加如下代码: // datebox单击文本框出现日期选择 start if ($(_83f).hasClass("datebox-f")) { _844.click(function() { _845.c

弹框提示用户输入

在很多页面,都会有提示用户输入账号和密码的弹框.并保障用户的良好体验效果. <html>   <head>   <title></title>   <meta http-equiv="content" content="text/html" charset="utf-8"/>   <style type="text/css">   body{   back

未加域客户端使用Lync时反复弹框要求输入凭证

最近发现部分未加域客户端打开Lync 2010时反复弹框要求输入凭证,且提示与Exchange进行连接时凭证错误,此时感觉问题原因因该是发生在两端客户端信息不匹配导致的,此时在Lync客户端帐号登录处输入完整域帐号(帐号@域名)后,并记住密码后无任何报错信息,且退出重新登录也不再提示,outlook相关日历信息也得到了正常同步. 未加域客户端使用Lync时反复弹框要求输入凭证,布布扣,bubuko.com

C#中的ComboBox实现只能选择不能输入,且下拉框中有默认值。

下拉框有DropDownStyle这一属性,把DropDownStyle类型选为DropDownList,则下拉框只能选择不能输入了.但是这时的下拉框是没有默认值的,即使在Text属性中输入默认值,也不起作用.就要在(某某某.Designer.cs)文件中修改.这是没有修改的:this.NameTemplateBox.Cursor = System.Windows.Forms.Cursors.Default; this.NameTemplateBox.DropDownStyle = System

NPOI_winfrom导出Excel表格(合并单元格、规定范围加外边框、存储路径弹框选择)

1.导出 1 private void btn_print_Click(object sender, EventArgs e) 2 { 3 DataTable dtNew = new DataTable(); 4 5 dtNew.Columns.Add(new DataColumn("commodity_name", typeof(object))); 6 dtNew.Columns.Add(new DataColumn("specifications", type

JS年月日三级联动下拉框日期选择代码

原博客网址: http://www.cnblogs.com/gdcgy/p/5467742.html 由于工作中涉及到生日编辑资料编辑,年月日用上面网址案例:bug提示: 编辑生日栏的[年]或者[月],之前保存的具体的[日]就不显示啦,产品说不管编辑哪个数据,其他数据不变: 然后自己改了一下代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xh