首页 文章 精选 留言 我的

精选列表

搜索[网站开发],共10000篇文章
优秀的个人博客,低调大师

iOS开发技巧 - 使用Alerts和Action Sheets显示弹出框

解决方案: (Swift) 使用UIAlertController类 (Objective-C) 使用UIAlertView类 代码: (Swift) import UIKit class ViewController: UIViewController { // 1. define the variable that will hold our alert controller var controller:UIAlertController? override func viewDidLoad() { super.viewDidLoad() // 2. start constructing a simple alert view controller using the alert view style controller = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert) // 3. simply print out a text to the console when pressed let action = UIAlertAction(title: "Done", style: UIAlertActionStyle.Default, handler: { (paramAction:UIAlertAction!) in println("The Done button was tapped") }) // 4. add the action that we created to the alert controller controller!.addAction(action) } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) // 5. present the alert controller self.presentViewController(controller!, animated: true, completion: nil) } } (Objective-C) #import "ViewController.h" @interface ViewController () <UIAlertViewDelegate> @end @implementation ViewController ... - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.view.backgroundColor = [UIColor whiteColor]; NSString *message = @"Are you sure you want to open this link in Safari?"; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Open Link" message:message delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [alertView show]; } - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex]; if ([buttonTitle isEqualToString:@"Yes"]){ NSLog(@"User pressed the Yes button."); } else if ([buttonTitle isEqualToString:@"No"]){ NSLog(@"User pressed the No button."); } }

优秀的个人博客,低调大师

iOS开发技巧 - 使用UIDatePicker来选择日期和时间

(Swift) import UIKit class ViewController: UIViewController { var datePicker: UIDatePicker! func datePickerDateChanged(datePicker: UIDatePicker) { println("Selected date = \(datePicker.date)") } override func viewDidLoad() { super.viewDidLoad() datePicker = UIDatePicker() datePicker.center = view.center view.addSubview(datePicker) datePicker.addTarget(self, action: "datePickerDateChanged:", forControlEvents: .ValueChanged) /* set the minimum and the maximum dates that it can display */ let oneYearTime:NSTimeInterval = 365 * 24 * 60 * 60 let todayDate = NSDate() let oneYearFromToday = todayDate.dateByAddingTimeInterval(oneYearTime) let twoYearsFromToday = todayDate.dateByAddingTimeInterval(2 * oneYearTime) datePicker.minimumDate = oneYearFromToday datePicker.maximumDate = twoYearsFromToday } } (Objective-C) #import "ViewController.h" @interface ViewController () @property (nonatomic, strong) UIDatePicker *myDatePicker; @end @implementation ViewController - (void) datePickerDateChanged:(UIDatePicker *)paramDatePicker { if ([paramDatePicker isEqual:self.myDatePicker]) { NSLog(@"Selected date = %@", paramDatePicker.date); } } - (void)viewDidLoad { [super viewDidLoad]; self.myDatePicker = [[UIDatePicker alloc] init]; self.myDatePicker.center = self.view.center; [self.view addSubview:self.myDatePicker]; [self.myDatePicker addTarget:self action:@selector(datePickerDateChanged:) forControlEvents:UIControlEventValueChanged]; NSTimeInterval oneYearTime = 365 * 24 * 60 * 60; NSDate *todayDate = [NSDate date]; NSDate *oneYearFromToday = [todayDate dateByAddingTimeInterval:oneYearTime]; NSDate *twoYearsFromToday = [todayDate dateByAddingTimeInterval:2 * oneYearTime]; self.myDatePicker.minimumDate = oneYearFromToday; self.myDatePicker.maximumDate = twoYearsFromToday; } @end

优秀的个人博客,低调大师

【AllJoyn框架-01】连接PC与Arduino Due开发

前言 从今天开始学习高通主打的物联网框架AllJoyn,并定期记录学习过程。由于目前网上教程很少,所以要认真阅读官方文档。下载回来的文档比较多,根据名字也不好判别先看哪个,后看哪个,所以目前就靠感觉先看一部分文档再说,若能看懂就照着做一遍,若看不懂就多看。大致原则就是先把部署过程熟悉,然后是基本概念,接着掌握SDK,最后才是源码的学习。本着开源分享的精神,学习笔记记录在此,以飨读者。 1、AllJoyn介绍 AllJoyn是一个中性平台系统,旨在简化邻近异构分布式移动通信网络系统。这里的异构性不仅表示不同的设备,而且可以是具有不同操作系统和不同类型的设备(例如个人电脑、手机、平板电脑和消费性电子产品),并且使用不同的通信技术。 2、需提前准备的资料 文档方面,网上资料并不多,只能求助于官方文档了,其分成了好几块,并不是完整的PDF。另外,源码是必须要有的,包括核心目录alljoyn_core、瘦客户端目录ajtcl等,文档中已给出了下载路径。在今天这个实验中,我重点看的文档是以下两个: Configuring the Thin Client BuildEnvironment (Arduino + Ethernet Shield).pdf configuring_the_build_envir_windows_xp_and_windows_7.pdf 硬件方面,alljoyn支持的平台还是挺多的,在这里我们就可看到它支持arduino。所以我选择的硬件平台是Arduino Due + 以太网扩展板 工具软件就采用arduino-1.5.6,其支持Due板 3、安装AJTC库到Arduino IDE 首先下载安装scons,不过先要把python安装好,它被安装到了python的Scripts文件夹中。正如上面第二个文档所说,我们要添加scons命令到环境变量 然后下载uncrustify,并且添加环境变量 最后进入到瘦客户端目录ajtcl,执行:scons TARG=arduino 那么就会在当前目录的build目录下生成arduino_due\libraries\AllJoyn,就可以在IDE中导入AllJoyn目录了 4、在Due中运行alljoyn瘦客户端实例AJ_LedService 选择文件-例子-AllJoyn-AJ_LedService,连接好硬件,点上传即可 5、在win7运行AllJoyn标准客户端AJSC 进入alljoyn_core目录,执行以下命令:scons OS=win7 CPU=x86 MSVC_VERSION=11.0 BINDINGS=cpp 一段时间过后,在build目录下就会有文件生成了 文档中说,若要将AJTC代码连接到AJSC,需要设置ALLJOYN_DIR环境变量到alljoyn目录,它是alljoyn_core的上一层目录 6、进入alljoyn_core\build\win7\x86_64\debug\dist\cpp\bin,执行例子ledctrl.exe: 保证刚才上传到Due板的AJ_LedService在运行,此时在上图命令行中输入on或off,就可使得板上led灯亮或灭。与此同时,在IDE的串口终端我们可以观察到相关输出: 在板上运行的其实是一个alljoyn bus object(服务),其向外公开了on和off方法。一旦有客户端连接到服务并循环接收命令时,on和off方法就会被调用。甚至当我们输入flash 100时,LED灯就会每100ms闪烁,这也就实现了运行在windows下alljoyn标准客户端与运行在嵌入式设备的瘦客户端间的通信。

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册