您的位置:首页 > 移动开发 > IOS开发

iOS 静态度制作方法详细

2016-01-06 10:48 344 查看
按照步骤和我一起来:

第一步:创建一个新的工程,选择Framework,然后选择cocoa Touch Static Libarary ,添加你自己想要的名字ok,这里我取为“myLibrary”



第二步:在myLibrary.h中添加并改为

[html] view
plaincopy

#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>

@interface myLibrary : NSObject

-(void)testFunction;

@end

第三步:在myLibrary.m中改为

[html] view
plaincopy

#import "myLibrary.h"

@implementation myLibrary

-(void)testFunction{

UIAlertView *myAlert=[[UIAlertView alloc] initWithTitle:@"哈哈,这个是静态库!"

message:@"成功了!"

delegate:self

cancelButtonTitle:@"取消"

otherButtonTitles:nil, nil];

[myAlert show];

[myAlert release];

}

@end

第四步:在左上角选择中改为iphone simulator



第五步:Bulid & Run ,会在Bulid文件夹里面有个libmyLibrary.a的文件

第六步:新建工程testLibrary



第七步:导入生成的libmyLibrary.a静态库和头文件,可以直接拖入到工程



第八步:在testLibrary 工程的

“ViewController.m”文件的viewDidLoad方法中添加

[html] view
plaincopy

#import "ViewController.h"

#import "myLibrary.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

myLibrary* pp=[[myLibrary alloc] init];

[pp testFunction];

[pp release];

}

第九步:Bulid & Run 我们的testLibrary 工程 然后九看到效果了



最后还有就是这个libmyLibrary.a静态库分为模拟器和真机的,切换也很方便就在



在这个地方切换为真机就ok了!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: