Iphone SDK ActionSheet 在当前窗口弹出时间选择
2010-06-13 15:48
309 查看
1.首先实现UIActionSheetDelete协议
2.
NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Set", nil];
[actionSheet showInView:self.view];
UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease];
datePicker.tag = 101;
// datePicker.datePickerMode = [(UISegmentedControl *)self.navigationItem.titleView selectedSegmentIndex];
[actionSheet addSubview:datePicker];
3.响应点击 Set后的函数
//根据 buttonIndex的参数的不同,进行处理。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
UIDatePicker *datePicker = (UIDatePicker *)[actionSheet viewWithTag:101];
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
formatter.dateFormat = @"MM/dd/YY h:mm a";
NSString *timestamp = [formatter stringFromDate:datePicker.date];
//显示时间的变量
[(UILabel *)[self.view viewWithTag:103] setText:timestamp];
[actionSheet release];
}
2.
NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Set", nil];
[actionSheet showInView:self.view];
UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease];
datePicker.tag = 101;
// datePicker.datePickerMode = [(UISegmentedControl *)self.navigationItem.titleView selectedSegmentIndex];
[actionSheet addSubview:datePicker];
3.响应点击 Set后的函数
//根据 buttonIndex的参数的不同,进行处理。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
UIDatePicker *datePicker = (UIDatePicker *)[actionSheet viewWithTag:101];
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
formatter.dateFormat = @"MM/dd/YY h:mm a";
NSString *timestamp = [formatter stringFromDate:datePicker.date];
//显示时间的变量
[(UILabel *)[self.view viewWithTag:103] setText:timestamp];
[actionSheet release];
}
相关文章推荐
- Iphone SDK ActionSheet 在当前窗口弹出时间选择
- C# 实现弹出选择窗口并传回值
- 关闭当前窗口弹出页面
- .NET C# 【小技巧】控制台程序,运行是否弹出窗口选择!
- iPhone开发【四】常用控件之ActionSheet与AlertView
- TextBox 内容由弹出窗口选择返回的实现
- 仿IOS ActionSheet控件从下弹出Dialog
- [唐胡璐]QTP技巧 - 添加Resource或Action时,不弹出相关路径窗口
- 2.UIActionSheet类(在iOS弹出的选择按钮项)
- iPhone开发学习笔记004——自定义背景透明非全屏弹出窗口,子类化UIWindow
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- jQuery弹出层始终垂直居中相对于屏幕或当前窗口
- iphone底部出现时间选择器(二)
- \cite{}不能弹出窗口选择
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- javaFX 可控制自动关闭时间的弹出提示窗口
- 打开新窗口,关闭当前页面,不弹出关闭提示。
- iphone 弹出表单UIActionSheet的应用。
- js判断选择时间不能小于当前时间的代码