2012年10月29日

获得iPhone的相关信息

摘要: 获取iphone的系统信息使用[UIDevicecurrentDevice],信息如下:[[UIDevice currentDevice] systemName]:系统名称,如iPhone OS[[UIDevice currentDevice] systemVersion]:系统版本,如4.2.1[[UIDevice currentDevice] model]:The model of the device,如iPhone或者iPod touch[[UIDevice currentDevice] uniqueIdentifier]:设备的惟一标识号,deviceID[[UIDevice cur 阅读全文

posted @ 2012-10-29 16:20 Solitary 阅读(188) 评论(0) 推荐(0) 编辑

xcode4 本地化多国语言

摘要: 1 xcode4.2,如果是简体中文,把国际化的文件放到zh-Hans.lproj中就显示正常了。如果放到zh.lproj中就不可以2 字符串1)在项目的“supporting files”目录中右键“new file”然后在弹出窗口左侧选择IOS的resource项,在右侧就可以看到“String File”的图标。创建这个文件,新建的文件名要写成“Localizable.strings” 必须是2)点击刚才创建的这个文件,选择的菜单中的“view”-》“utilities”-》“file inspect” 右侧会看到一些属性的信息3)找到Localization这项,现在应该是空的,点“+ 阅读全文

posted @ 2012-10-29 16:16 Solitary 阅读(186) 评论(0) 推荐(0) 编辑

Set the Zoom Level of an MKMapView

摘要: If you have ever built a web application using the Google Maps API, you are likely intimately familiar with this line of code:map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);The setCenter JavaScript method takes in the center coordinate and a zoom level. The zoom level, as you might ex 阅读全文

posted @ 2012-10-29 16:13 Solitary 阅读(474) 评论(0) 推荐(0) 编辑

iOS 地图与定位开发系列教程(四)

摘要: MKPlacemark、MKUserLocation和MKReverseGeocoder在地图上做标记是通过MKPlacemark类来完成的。这个类使用(符合)MKAnnotation协议。MKAnnotation包含了多个属性,如:位置(经纬度,CLLocationCoordinate2D类型)、文字标记信息(NSString类型)等。MKPlacemark保存了位置(经纬度)和地址(字典类)之间的映射。下面是它的初始化方法:-(void)initWithCoordinate:(CLLocationCoordinate2D *)coordinate addressDictionary:(NS 阅读全文

posted @ 2012-10-29 16:05 Solitary 阅读(376) 评论(0) 推荐(0) 编辑

iOS 地图与定位开发系列教程(三)

摘要: MapKit框架主要提供了四个功能:1、显示地图;2、CLLocation和地址之间的转换;3、支持在地图上做标记(比如标记北京天安门广场);4、 把一个位置解析成地址(比如我在水立方,想要知道确切的地址信息)。MKMapView类主要是完成下述功能:1、显示地图,比如:显示北京市的地图;2、提供多种显示方式,比如标准地图格式,卫星地图等;3、支持地图的放大缩小;4、支持在地图上做标记,比如标记天安门广场;5、在地图上显示手机所在的当前位置。MKMapView类的属性有:@property MKCoordinateRegin region; //地图所显示的区域@property CLLoca 阅读全文

posted @ 2012-10-29 16:03 Solitary 阅读(267) 评论(0) 推荐(0) 编辑

iOS 地图与定位开发系列教程(二)

摘要: 下面我们来看一个位置类的基本步骤:一、启动定位服务CLLocationManager *locManager = [[CLLocationManager alloc] init];locManager.delegate = self;[locManager startUpdatingLocation];二、获得位置信息-(void)locationManager:(CLLocationManager *)managerdidUpdateToLocation:(CLLocation *)newLocation fromLocation: (CLLocation *)oldLocation{NST 阅读全文

posted @ 2012-10-29 15:59 Solitary 阅读(188) 评论(0) 推荐(0) 编辑

iOS 地图与定位开发系列教程(一)

摘要: iPhone SDK提供了三个类来管理位置信息:CLLocation CLLocationManager 和 CLLHeading(不常用)。除了使用GPS来获取当前的位置信息外,iPhone也可以基于WiFi基站和无线发射塔来获得位置信息。GPS的精度最高,可以精确到米级别,但是也最耗电。1、CLLocationCLLocation类代表一个位置信息,其中还包括了方向和速度。比如我在长安街188号以5公里/小时的速度往西走。CLLocation具有下面的属性和方法:@property CLLocationCoordinate2D coordinate; //以经度和纬度表示的位置信息@pr. 阅读全文

posted @ 2012-10-29 15:56 Solitary 阅读(261) 评论(0) 推荐(0) 编辑

IOS atomic与nonatomic,assign,copy与retain的定义和区别

摘要: atomic和nonatomic用来决定编译器生成的getter和setter是否为原子操作。atomic:设置成员变量的@property属性时,默认为atomic,提供多线程安全。 在多线程环境下,原子操作是必要的,否则有可能引起错误的结果。加了atomic,setter函数会变成下面这样: {lock} if (property != newValue) { [property release]; property = [newValue retain]; } {un... 阅读全文

posted @ 2012-10-29 15:49 Solitary 阅读(164) 评论(0) 推荐(0) 编辑

imageNamed 与 imageWithContentsOfFile的区别

摘要: 用UIImage加载图像的方法很多,最常用的是下面两种:1.用imageNamed函数,例如:[UIImage imageNamed:ImageName];2.用NSData的方式加载,例如:NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:extension];NSData *image = [NSData dataWithContentsOfFile:filePath];[UIImage imageWithData:image];由于第一种方式要写的代码比较少,可能比较多人利用imageN 阅读全文

posted @ 2012-10-29 15:40 Solitary 阅读(148) 评论(0) 推荐(0) 编辑

DateDiff 在 Objective-C 中的实现

摘要: /* dateDiff 方法实现 */ +(NSDateComponents *) dateDiff:(NSDate *) fromDate toDate:(NSDate *) toDate{ NSCalendar *sysCalendar = [NSCalendar currentCalendar]; unsigned int unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | ... 阅读全文

posted @ 2012-10-29 15:32 Solitary 阅读(170) 评论(0) 推荐(0) 编辑

iOS Developer Library 收藏目录

摘要: App Icons on iPad and iPhoneAutomatic orientation support for iPhone and iPad appsProgramming Apple Push Notification Services 阅读全文

posted @ 2012-10-29 15:27 Solitary 阅读(130) 评论(0) 推荐(0) 编辑

iOS 5 编程使用ARC的一些规则

摘要: 使用ARC的一些规则:1. 不允许调用对象的retain, release, auto-relase, retain count等方法,也不允许通过类似@selector(retain)的方法进行间接调用。2. 不允许调用对象的dealloc方法。 虽然重定义类的dealloc方法是允许的,但不能在其中调用[super dealloc]或任何成员变量的dealloc方法,只允许进行一些善后工作,比如释放某些文件资源。3. 在@property声明中,不再允许使用retain, copy, assign等关键字,取而代之的是两个新关键字:strong和weak。4. 当结构中包含对象指针时,最好 阅读全文

posted @ 2012-10-29 15:22 Solitary 阅读(156) 评论(0) 推荐(0) 编辑

导航