IOS地图开发 简介 IOS地图帮助我们定位位置,IOS地图使用 MapKit 框架。 实例步骤 1.创建一个简单的 View based application 2.选择项目文件,然后选择目标,然后添加MapKit.framework. 3.添加 Corelocation.framework 4.向 ViewController.xib 添加地图查看和创建 ibOutlet 并且命名为mapView。 5.通过”File-> New -> File… -> “选择 Objective C class创建一个新的文件,单击下一步 6.”sub class of”为 NSObject,类作命名为MapAnnotation 7.选择创建 8.更新MapAnnotation.h ,如下所示 #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interface MapAnnotation : NSObject<MKAnnotation> @property (nonatomic, strong)…

IOS音频和视频(Audio & Video) 简介 音频和视频在最新的设备中颇为常见。 将iosAVFoundation.framework和MediaPlayer.framework添加到Xcode项目中,可以让IOS支持音频和视频(Audio & Video)。 实例步骤 1、创建一个简单的View based application 2、选择项目文件、选择目标,然后添加AVFoundation.framework和MediaPlayer.framework 3、在ViewController.xib中添加两个按钮,创建一个用于分别播放音频和视频的动作(action) 4、更新ViewController.h,如下所示 #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> #import <MediaPlayer/MediaPlayer.h> @interface ViewController : UIViewController { AVAudioPlayer *audioPlayer; MPMoviePlayerViewController *moviePlayer; } -(IBAction)playAudio:(id)sender; -(IBAction)playVideo:(id)sender; @end 5、更新ViewController.m,如下所示 #import “ViewController.h” @interface ViewController () @end @implementation ViewController – (void)viewDidLoad…

IOS发送电子邮件 简介 我们可以使用IOS设备中的电子邮件应用程序发送电子邮件。 实例步骤 1、创建一个简单的View based application 2、选择项目文件,然后选择目标,然后添加MessageUI.framework 3、在ViewController.xib中添加一个按钮,创建用于发送电子邮件的操作(action) 4、更新ViewController.h,如下所示 #import <UIKit/UIKit.h> #import <MessageUI/MessageUI.h> @interface ViewController : UIViewController<MFMailComposeViewControllerDelegate> { MFMailComposeViewController *mailComposer; } -(IBAction)sendMail:(id)sender; @end 5、如下所示,更新ViewController.m #import “ViewController.h” @interface ViewController () @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; } – (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; //…

IOS文件处理 简介 文件处理不能直观的通过应用程序来解释,我们可以从以下实例来了解IOS的文件处理。 IOS中对文件的操作. 因为应用是在沙箱(sandbox)中的,在文件读写权限上受到限制,只能在几个目录下读写文件。 文件处理中使用的方法 下面列出了用于访问和操作文件的方法的列表。 以下实例你必须替换FilePath1、FilePath和FilePath字符串为完整的文件路径,以获得所需的操作。 检查文件是否存在 NSFileManager *fileManager = [NSFileManager defaultManager]; //Get documents directory NSArray *directoryPaths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [directoryPaths objectAtIndex:0]; if ([fileManager fileExistsAtPath:@””]==YES) { NSLog(@”File exists”); } 比较两个文件的内容 if ([fileManager contentsEqualAtPath:@”FilePath1″ andPath:@” FilePath2″]) { NSLog(@”Same content”);…

IOS SQLite数据库 简介 在IOS中使用Sqlite来处理数据。如果你已经了解了SQL,那你可以很容易的掌握SQLite数据库的操作。 实例步骤 1、创建一个简单的View based application 2、选择项目文件,然后选择目标,添加libsqlite3.dylib库到选择框架 3、通过选择” File-> New -> File… -> “选择 Objective C class 创建新文件,单击下一步 4、”sub class of”为NSObject”,类命名为DBManager 5、选择创建 6、更新DBManager.h,如下所示 #import <Foundation/Foundation.h> #import <sqlite3.h> @interface DBManager : NSObject { NSString *databasePath; } +(DBManager*)getSharedInstance; -(BOOL)createDB; -(BOOL) saveData:(NSString*)registerNumber name:(NSString*)name department:(NSString*)department year:(NSString*)year; -(NSArray*)…

IOS定位操作 简介 在IOS中通过CoreLocation定位,可以获取到用户当前位置,同时能得到装置移动信息。 实例步骤 1、创建一个简单的View based application(视图应用程序)。 2、择项目文件,然后选择目标,然后添加CoreLocation.framework,如下所示 3、在ViewController.xib中添加两个标签,创建ibOutlet名为latitudeLabel和longtitudeLabel的标签 4、现在通过选择” File-> New -> File… -> “选择Objective C class 并单击下一步 5、把”sub class of”作为NSObject,将类命名为LocationHandler 6、选择创建 7、更新LocationHandler.h,如下所示 #import <Foundation/Foundation.h> #import <CoreLocation/CoreLocation.h> @protocol LocationHandlerDelegate <NSObject> @required -(void) didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation; @end @interface LocationHandler : NSObject<CLLocationManagerDelegate> { CLLocationManager *locationManager; } @property(nonatomic,strong)…

IOS相机管理 相机简介 相机是移动设备的共同特点之一,我们能够使用相机拍摄图片,并在应用程序里调用它,而且相机的使用很简单。 实例步骤 1、创建一个简单的View based application 2、在ViewController.xib中添加一个button (按钮),并为该按钮创建IBAction 3、添加一个 image view (图像视图),并创建一个名为imageView的IBOutlet 4、ViewController.h文件代码如下所示: #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIImagePickerControllerDelegate> { UIImagePickerController *imagePicker; IBOutlet UIImageView *imageView; } – (IBAction)showCamera:(id)sender; @end 5、修改ViewController.m,如下所示: #import “ViewController.h” @interface ViewController () @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; }…

IOS通用应用程序 简介 通用的应用程序是为iPhone和iPad在一个单一的二进制文件中设计的应用程序。这有助于代码重用,并能够帮助更快进行更新。 实例步骤 1、创建一个简单的View based application(视图应用程序) 2、在文件查看器的右边,将文件ViewController.xib的文件名称更改为ViewController_iPhone.xib,如下所示 3、选择”File -> New -> File… “,然后选择User Interface,再选择View,单击下一步 4、选择iPad作为设备,单击下一步: 5、将该文件另存为ViewController_iPad.xib,然后选择创建 6、在ViewController_iPhone.xib和ViewController_iPad.xibd的屏幕中心添加标签 7、在ViewController_iPhone.xib中选择identity inspector,设置custom class为ViewController 8、更新AppDelegate.m中的 application:DidFinishLaunching:withOptions方法 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. if…

IOS加速度传感器(accelerometer) 简介 加速度传感器是根据x、y和z三个方向来检测在设备位置的改变。 通过加速度传感器可以知道当前设备相对于地面的位置。 以下实例代码需要在真实设备上运行,在模拟器上是无法工作的。 实例步骤 1、创建一个简单的视图应用程序 2、在ViewController.xib中添加三个标签,并创建一个ibOutlets分别为:xlable、ylabel和zlabel 3、如下所示,更新ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIAccelerometerDelegate> { IBOutlet UILabel *xlabel; IBOutlet UILabel *ylabel; IBOutlet UILabel *zlabel; } @end 4、如下所示,更新ViewController.m #import “ViewController.h” @interface ViewController () @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; [[UIAccelerometer sharedAccelerometer]setDelegate:self]; //Do any…

IOS图标的使用 IOS图标是用于应用程序相关的操作。 IOS 中的不同图标 AppIcon App Store 的应用程序图标 搜索结果和设置的小图标 工具栏和导航栏图标 选项卡栏图标 AppIcon AppIcon 是出现在设备SpringBoard (默认屏幕上的所有的应用程序) 的应用程序的图标。 App Store 的应用程序图标 它是512 x 512 或 1024 x 1024(推荐大小)的高分辨率的应用程序图标。 搜索结果和设置的小图标 在搜索列表的应用程序中使用这个小图标。 它还用于与相关的应用程序的功能是启用和禁用的设置屏幕上。如:启用定位服务。 工具栏和导航栏图标 工具栏和导航栏中使用特制的标准图标的列表。它包括的份额,像图标相机,撰写等等。 选项卡栏图标 选项卡栏中使用一系列特制的标准图标列表。它包括的图标有书签、 联系人、 下载等。 有的不同的 iOS 设备的每个图标大小的都不一样。你可以查看更多关于苹果文件中图标的准则:ios人机交互界面指南。