1.创建第一个程序
1).创建项目 ,然后添加一个新的viewcontroller文件,这时会生成.h .m .xib文件 ,在项目 名称appdeletegate.h中添加
UINavigationController *mainNavigation;
2).在.m文件中application方法中添加
//别忘记 导入包
mainNavigation=[[UINavigationController alloc]init ];

mainNavigation=[[UINavigationController alloc]init ];
MainViewController*mainView=[[MainViewController alloc]init ];
mainView.title=@"主页面";
//将viewcontroller添加到主导航器中
[mainNavigation pushViewController:mainView animated:NO];
//将mainNavigation作为程序的导航器
[self.window addSubview:mainNavigation.view];
//将mainview释放
[mainView release];

3).接下来要定义事件关联
在mainviewcontroller.h文件中声明变量,是为了与界面中的两个组件关联

IBOutlet UILabel*label;
IBOutlet UIButton *button;
4).声明方法
-(IBAction)clickBtn:(id)sender;
5).在.m文件中实现这个方法
-(IBAction)clickBtn:(id)sender{
NSLog(@"click.....");
label.text=@"Hello....";
}
6).打开IB,点击”file owner”图标,将里面的属性拖动到对应的组件上,将方法拖到按钮上,这时会显示所有事件,选中一个

2.页面跳转 与传值
1).创建一个viewcontroller,在mainview中导入此文件的接口
声明实例,如下:
CarNoViewController *carnoView=[[CarNoViewController alloc]init ];
carnoView.title=@"车牌号";
carnoView.userName=@"bushi";
[self.navigationController pushViewController:carnoView animated:YES];
[carnoView release];
2)在第二个viewcontroller中的.h文件中声明一个属性,如下
int age;
NSString *userName;
//注意,上面是在{}中,下面是在外面
@property (nonatomic,retain)NSString *userName;
@property int age;
在.m文件中添加
//@implementation CarNoViewController
@synthesize age;
@synthesize userName;

在第一个viewcontroller中就可以设置此实例中的此属性值了

1.通过拖动OBJECT添加类类:
在 XIB界面添加OBJECT对象,在属 性中输入类名,接着点击类名后面的一个灰色箭头,会显示此类的另一些属性
在IBOUTLET和IBACTION中输入属 性和方法
双 击刚才添加的OBJECT,会显示新添加的属性和方法,将属性和方法拖动到对应的组件中
2。为为程序添加图标图标
将一个图片文件拖到RESOURCE文件夹中,打开PLIST文件,修改里面的ICONFILE值为@"icon.png"即可
3.定义数组
NSArray *userNameArray=[NSArray arrayWithObjects:@"Bushi",@"Aobama",@"Kelindun",nil];
//取数组中某个数据
label1.text=[NSString stringWithFormat:@"%@",[userNameArray objectAtIndex:0]];

4.titleView添加按钮
在要添加的viewcontroller中的viewdidload添加如下代码

UIView *titleView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 20)];
[titleView setBackgroundColor:[UIColor clearColor]];

UIButton *titleBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[titleBtn setFrame:CGRectMake(0, 0, 40, 20)];
[titleBtn addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[titleBtn setTitle:@"Help" forState:UIControlStateNormal];
[titleBtn setFont:[UIFont systemFontOfSize:8]];
[titleView addSubview:titleBtn];

self.navigationItem.titleView=titleView;
[titleView release];

5.TableView添加数据
1)。在H文件中声明
NSArray *m_data;
并添加
@property (nonatomic,retain)NSArray*m_data;
2)。在M文件IMPLEMENTION下面添加
@synthesize m_data;
3)在VIEWDIDLOAD中添加如下代码
NSArray *arr=[[NSArray alloc]initWithObjects:@"Jinan",@"Beijing",@"上海",nil];
self.m_data=arr;
[arr release];
4)继续在M文件下面添加如下方法
-(NSInteger)tableView:(UITableView*)tableView
numberOfRowsInSection:(NSInteger)section{
return [m_data count];

}
-(UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)
indexPath{
static NSString *TableViewDynamicLoadIDentifier=
@"TableViewDynamicLoadIdentifier";
UITableViewCell *pCell=[tableView dequeueReusableCellWithIdentifier:TableViewDynamicLoadIDentifier];
if(pCell==nil){
pCell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TableViewDynamicLoadIDentifier]autorelease];

}
NSInteger nRow=[indexPath row];
pCell.textLabel.text=[m_data objectAtIndex:nRow];
return pCell;
}

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
NSUInteger row=indexPath.row;
NSString *s=[NSString stringWithFormat:@"%d",row];
NSLog(s);
}

//设置行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 65.0f;
}

6,CoreData 核心数据
添加开发支持
1)点击FRAMEWORKS目录,右键添加FRAMWORK中的COREDATA
2)双击生成的XCDATAMODEL文件
3)添加对象和属性,建立关系
4)FILE-NEW FILE-COCOATOUCHCLASS-MANAGEDOBJECTCLASS
在H文件中声明
NSManagedObjectContext * manageObjectCon;
@property (nonatomic,retain)NSManagedObjectContext *manageObjectCon;

在M文件中

@synthesize manageObjectCon;

-(NSManagedObjectContext *)manageObjectCon{
if(manageObjectCon==nil){
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath=([paths count]>0) ? [paths objectAtIndex:0]:nil;
NSURL*url=[NSURL fileURLWithPath:[basePath stringByAppendingPathComponent:@"books.sqlite"]];
NSError*err;
NSPersistentStoreCoordinator*persistentStoreCoordinator=
[[NSPersistentStoreCoordinator alloc]initWithManagedObjectModel:[NSManagedObjectModel mergedModelFromBundles:nil]];
if(![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:nil error:&err])
{
NSLog(@"Failed to add persistent store with type to persistent store coordinator");
}
manageObjectCon=[[NSManagedObjectContext alloc]init];
[manageObjectCon setPersistentStoreCoordinator:persistentStoreCoordinator];

}
return manageObjectCon;
}

-(void)demo{
//save two book and author
Book *b1=(Book *)[NSEntityDescription insertNewObjectForEntityForName:@"Book" inManagedObjectContext:self.manageObjectCon];
Book *b2=(Book *)[NSEntityDescription insertNewObjectForEntityForName:@"Book" inManagedObjectContext:self.manageObjectCon];

Author *a1=(Author*)[NSEntityDescription insertNewObjectForEntityForName:@"Author" inManagedObjectContext:self.manageObjectCon];
Author *a2=(Author*)[NSEntityDescription insertNewObjectForEntityForName:@"Author" inManagedObjectContext:self.manageObjectCon];

b1.name=@"Android Development";
a1.name=@"LLG";
b2.name=@"Iphone Development";
a2.name=@"LuLiGuo";
[a1 addWriteRelationshipObject:b1];
[a2 addWriteRelationshipObject:b2];

// read data from coredata
NSArray*booksAuthor2Wrote=[a2.writeRelationship allObjects];
for(int i=0;i<[booksAuthor2Wrote count];i++){
Book *tempBook=(Book *)[booksAuthor2Wrote objectAtIndex:i];
NSLog(@"book %@ wrote include:%@",a2.name,tempBook.name);
}

}
在应用程序的加载中添加
[self manageObjectCon];
[self demo];

添加记录
Article *article1=(Article *)[NSEntityDescription insertNewObjectForEntityForName:@"Article" inManagedObjectContext:manageObjectCon];
article1.title=@"Title1";

查询某个对象所有记录
-(IBAction)queryData:(id)sender{

NSError *error;
NSLog(@"query...");
NSFetchRequest*fetchRequest=[[NSFetchRequest alloc]init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Article" inManagedObjectContext:manageObjectCon]];
NSSortDescriptor*sortDescriptor=[[NSSortDescriptor alloc]initWithKey:@"title" ascending:YES selector:nil];
NSArray*descriptors=[NSArray arrayWithObject:sortDescriptor];
[fetchRequest setSortDescriptors:descriptors];
NSPredicate*pred=[NSPredicate predicateWithFormat:@"(title=%@)",@"Title1"];//按条件查询
[fetchRequest setPredicate:pred];
NSArray*objects=[manageObjectCon executeFetchRequest:fetchRequest error:&error];
int c=[objects count];
NSLog(@"count is %d",c);
for (int i=0; i<[objects count]; i++) {
Article*a=(Article*)[objects objectAtIndex:i][NSArray alloc]nitWithObjects:@"Hello",@"HAHA",@"Heihei",nil];
self.listData=array;
[array release];
6).添加如下方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [self.listData count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text=[listData objectAtIndex:indexPath.row];
cell.detailTextLabel.text=@"Detail..";
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
return cell;
}
7)在viewDidUnload中添加self.listData=nil;
8)在dealloc方法中添加[listData release];
9)最后就是把viewcontroller显示在界面上了
sysNavigation=[[UINavigationController alloc]init];
TableViewController1 *tvc=[[TableViewController1 alloc]init];
tvc.title=@"TABLEVIEW";
[sysNavigation pushViewController:tvc animated:NO];
[window addSubview:sysNavigation.view];

8.如何使用sqlite
1)点击项目中的frameworks,鼠标右键,添加libssqlite3.dylib
2)在.h文件中导入包 #import "sqlite3.h"
3)定义sqlite3 *database_;
BOOL *bFirstCreate;
4)在.m文件中导入包#import "sqlite3.h"
5)定义如下方法

-(BOOL)open{
NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString*documentsDirectory=[paths objectAtIndex:0];
NSString*path=[documentsDirectory stringByAppendingPathComponent:@"mydb.sql"];
NSFileManager*fileManager=[NSFileManager defaultManager];
BOOL find=[fileManager fileExistsAtPath:path];
//找到数据库文件MYDB。SQL
if(find){
NSLog(@"数据库文件已经找到 ");
if(sqlite3_open([path UTF8String], &database_)!=SQLITE_OK){
sqlite3_close(database_);
NSLog(@"打开数据库文件错误 。。。。");
return NO;
}
return YES;
}
if(sqlite3_open([path UTF8String], &database_)==SQLITE_OK){
bFirstCreate=YES;
[self createChannelsTable:database_];
return YES;
}else{

sqlite3_close(database_);
NSLog(@"打开数据库文件出错");
return NO;
}
return NO;

}

//创建文件表
-(BOOL)createArticleTable:(sqlite3*)db{
NSLog(@"创 建文件表");
char*errorMsg;
NSString*createSQL=@"create table if not exists Article(aid integer primary key,title text,content text);";
if(sqlite3_exec(database_, [createSQL UTF8String], NULL, NULL, &errorMsg)!=SQLITE_OK)
{
sqlite3_close(database_);
NSAssert1(0,@"Error creating table :%s",errorMsg);
}
return YES;

}

6)在应用程序启动的方法中添加
[self open];
[self createArticleTable:database_];
7)添加记录的方法
-(IBAction)insertData:(id)sender{
NSLog(@"start insertdata().....");
char *insert="insert or replace into Article(aid,title,content) values(?,?,?);";
sqlite3_stmt *stmt;
if(sqlite3_prepare_v2(database_, insert, -1, &stmt, nil)==SQLITE_OK){
//sqlite3_bind_int(stmt, 1, 1);
sqlite3_bind_text(stmt, 2, [@"title1" UTF8String], -1, NULL);
sqlite3_bind_text(stmt, 3, [@"content1" UTF8String], -1, NULL);
}
if (sqlite3_step(stmt)!=SQLITE_DONE) {
NSLog(@"error insert data....");
}
sqlite3_finalize(stmt);
}

-(IBAction)deleteData:(id)sender{
NSLog(@"start deletedata().....");
char *insert="delete from Article where title=?;";
sqlite3_stmt *stmt;
if(sqlite3_prepare_v2(database_, insert, -1, &stmt, nil)==SQLITE_OK){
sqlite3_bind_text(stmt, 1, [@"title1" UTF8String], -1, NULL);

}
if (sqlite3_step(stmt)!=SQLITE_DONE) {
NSLog(@"error delete data....");
}
sqlite3_finalize(stmt);

}
-(IBAction)updateData:(id)sender{
}
-(IBAction)queryData:(id)sender{
NSLog(@"start querydata().....");
NSString *query=@"SELECT TITLE,CONTENT FROM ARTICLE";
sqlite3_stmt*stmt;
if(sqlite3_prepare_v2(database_, [query UTF8String], -1, &stmt, nil)==SQLITE_OK){
while (sqlite3_step(stmt)==SQLITE_ROW) {
//如果某列是int则为 int i=sqlite3_column_int();
char *t=(char *)sqlite3_column_text(stmt, 0);
char *c=(char *)sqlite3_column_text(stmt, 1);

NSString *title=[[NSString alloc]initWithUTF8String:t];
NSString *content=[[NSString alloc]initWithUTF8String:c];
NSLog(@"title is %@",title);
}

}else {
NSLog(@"LLG:Connect to database has error....");
}

}

9.拖动效果 左右拖动 轻扫
在M文件中添加如下方法

#pragma mark label
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
isAdd=1;
NSLog([@"touchesBegan....." stringByAppendingFormat:@"%d",isAdd]);
UITouch*touch=[touches anyObject];
gestureStartPoint=[touch locationInView:self.view];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch*touch=[touches anyObject];
CGPoint currentPosition=[touch locationInView:self.view];
CGFloat deltax=fabsf(gestureStartPoint.x-currentPosition.x);
CGFloat deltay=fabsf(gestureStartPoint.y-currentPosition.y);

if (deltax>=kMiniMMGestureLength&&deltay<=kMaximmVariance) {
if (gestureStartPoint.x>currentPosition.x) {
NSLog(@"Horizontal left swipe detected");

}}

}

10.自定义tableViewCell 样式

将一个tableview拖到界面上,alt+2 关连数据库和维拖
.h文件中
#import <UIKit/UIKit.h>
#define kNameValueTag 1
#define kColorValueTag 2

@interface MainViewController : UIViewController
<UITableViewDataSource,UITableViewDelegate>
{

NSArray *computers;
}

@property (nonatomic,retain) NSArray*computers;
@end

.m文件中

@synthesize computers;

- (void)viewDidLoad {
NSDictionary*row1=[[NSDictionary alloc]initWithObjectsAndKeys:@"MacBook",@"Name",@"White",@"Color" ,nil];
NSDictionary*row2=[[NSDictionary alloc]initWithObjectsAndKeys:@"MacBook Pro",@"Name",@"Silver",@"Color" ,nil];
NSDictionary*row3=[[NSDictionary alloc]initWithObjectsAndKeys:@"iMac",@"Name",@"Silver",@"Color" ,nil];
NSDictionary*row4=[[NSDictionary alloc]initWithObjectsAndKeys:@"MacBook",@"Name",@"White",@"Color" ,nil];

NSArray*array=[[NSArray alloc]initWithObjects:row1,row2,row3,row4,nil ];
self.computers=array;
[row1 release];
[row2 release];
[row3 release];
[row4 release];
[array release];
[super viewDidLoad];
}

-(NSInteger)tableView:(UITableView*)tableView
numberOfRowsInSection:(NSInteger)section{
return [computers count];

}
-(UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)
indexPath{
static NSString*CellTableIdentifier=@"CellTableIdentifier";

UITableViewCell *pCell=[tableView dequeueReusableCellWithIdentifier:CellTableIdentifier];
if(pCell==nil){
pCell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellTableIdentifier]autorelease];
CGRect nameLabelRect=CGRectMake(0, 5, 70, 15);
UILabel*nameLabel=[[UILabel alloc]initWithFrame:nameLabelRect ];
nameLabel.textAlignment=UITextAlignmentRight;
nameLabel.text=@"Name:";
nameLabel.font=[UIFont boldSystemFontOfSize:12];
[pCell.contentView addSubview:nameLabel];
[nameLabel release];

CGRect colorLabelRect=CGRectMake(0, 26, 70, 15);
UILabel *colorLabel=[[UILabel alloc]initWithFrame:colorLabelRect ];
colorLabel.textAlignment=UITextAlignmentRight;
colorLabel.text=@"Color:";
colorLabel.font=[UIFont boldSystemFontOfSize:12];
[pCell.contentView addSubview:colorLabel];
[colorLabel release];

CGRect nameValueRect=CGRectMake(80, 5, 200, 15);
UILabel *nameValue=[[UILabel alloc]initWithFrame:nameValueRect ];
nameValue.tag=kNameValueTag;
[pCell.contentView addSubview:nameValue];
[nameValue release];

CGRect colorValueRect=CGRectMake(80, 25, 200, 15);
UILabel *colorValue=[[UILabel alloc]initWithFrame:colorValueRect ];

colorValue.tag=kColorValueTag;
[pCell.contentView addSubview:colorValue];
[colorValue release];

}
NSInteger row=[indexPath row];
NSDictionary *rowData=[self.computers objectAtIndex:row];
UILabel*name=(UILabel*)[pCell.contentView viewWithTag:kNameValueTag];
name.text=[rowData objectForKey:@"Name"];
UILabel*color=(UILabel*)[pCell.contentView viewWithTag:kColorValueTag];
color.text=[rowData objectForKey:@"Color"];
return pCell;
}

16.TableView 分组表
1).在resources文件夹下创建plist文件
2).拖一个tableview到界面,并设置datasource和delegate
3).更改tableview的样式style为 Grouped
4).在.h文件中声明
@interface SectionsViewController : UIViewController
 <UITableViewDataSource, UITableViewDelegate>
 {
  NSDictionary *names;
  NSArray     *keys;
 }
 @property (nonatomic, retain) NSDictionary *names;
 @property (nonatomic, retain) NSArray *keys;
5)在.m文件中
@synthesize names;
@synthesize keys;
6).在viewdidload中
//获取属性列表的路径   sortednames.plist
    NSString *path = [[NSBundle mainBundle] pathForResource:@"sortednames"
                                                     ofType:@"plist"];
 
//实例化一个字典
   
NSDictionary *dict = [[NSDictionary alloc]
                          initWithContentsOfFile:path];
   
self.names = dict;
    [dict release];
   
   
NSArray *array = [[names allKeys][NSArray alloc]initWithObjects:@"One",@"Two",@"Three",nil ];
NSArray*arr2=[[NSArray alloc]initWithObjects:@"One1",@"Two1",@"Three1",nil ];

NSDictionary*dict=[[NSDictionary alloc]initWithObjectsAndKeys:arr1,@"Title1",arr2,@"Title2",nil];

*/

7).在最后添加如下代码
#pragma mark -
#pragma mark Table View Data Source Methods
//获取分区的数量 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [keys count];
}
//获取分区里的行的数量
//section为其中的一个分区
- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    NSString *key = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
    return [nameSection count];
}

//行的创建
- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 //获取第几分区
    NSUInteger section = [indexPath section];
 //获取行
    NSUInteger row = [indexPath row];
   
    NSString *key = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
   
    static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
                             SectionsTableIdentifier ];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier: SectionsTableIdentifier ] autorelease];
    }
   
    cell.textLabel.text = [nameSection objectAtIndex:row];
    return cell;
}
//为每个分区指定一个名称  现在的名称为key的值
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
    NSString *key = [keys objectAtIndex:section];
    return key;
}
//添加索引,索引的值为右侧的a--z
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    return keys;
}

15.自定义TableViewCell
-(void)makeSubCell:(UITableViewCell *)aCell withTitle:(NSString *)title
value:(NSString *)value
{
CGRect tRect = CGRectMake(20,5, 50, 40);
id lbl = [[UILabel alloc] initWithFrame:tRect]; //此处使用id定义任何控件对象
[lbl setText:title];
[lbl setBackgroundColor:[UIColor clearColor]];

CGRect tEdtRect = CGRectMake(50,15, 320, 40);
id edtPassword = [[UILabel alloc] initWithFrame:tEdtRect];
[edtPassword setText:value];
[edtPassword setBackgroundColor:[UIColor clearColor]];
//[edtPassword setKeyboardType:UIKeyboardTypeNumberPad];
// [edtPassword setSecureTextEntry:YES];
CGRect iEdtRect = CGRectMake(50,15, 320, 40);
id ima = [[UIImageView alloc] initWithFrame:tEdtRect];

[aCell addSubview:lbl];
[aCell addSubview:edtPassword];
[aCell addSubview:ima];

//release someone
[lbl release];
[edtPassword release];

}

//函数二 表格控制函数
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"Simple";

UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SimpleTableIdentifier] autorelease];
NSUInteger row = [indexPath row];

switch (row) {
case 0:
[self makeSubCell:cell withTitle:@"A:" value:@"password"];
break;
case 1:
[self makeSubCell:cell withTitle:@"B:" value:@"new password"];
break;
case 2:
[self makeSubCell:cell withTitle:@"C:" value:@"confirm password"];
break;
case 3:
[self makeSubCell:cell withTitle:@"D:" value:@"confirm password"];
break;
}
if (cell == nil)
{
NSLog(@"cell = nil");
}else
{
NSLog(@"cell <> nil");
}
return cell;
}

17.解析xml libxml 2.2
1.添加 libxml2 frameworks
   xcode中右击 "FrameWorks" ->Add->Add existing FWrameorks ,选择 "DyLibs",在其中选取libxml2 的dylib包,我选取的是 libxml2.2.7.3.dylib ,Add 即可
 
2.设置"Header Search Paths"
  在xcode中project->edit project settings->build 找到 "search paths",然后在Header Search Paths中添加
Xml代码  HYPERLINK "javascript:void()"
/usr/include/libxml2  
 这样添加也可以:
Xml代码  HYPERLINK "javascript:void()"
/Developer/Platforms/iPhoneOS.platform/Develope/SDKs/iPhoneOS4.0.sdk/usr/include/libxml2

18.多线程
// NSThread*t1=[[NSThread alloc]initWithTarget:self selector:@selector(jishi) object:nil ];
// [t1 start];
19记时器
NSTimer*myTimer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(jishi) userInfo:nil repeats:YES];

20.数据存储 NSUserDefaults

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSString stringWithFormat:@"%d",time] forKey:@"ESS_STUDY_TIME"];
[defaults synchronize];

//NSString *testStr = [defaults objectForKey:@"myTest"];
//NSLog(@"testStr is: %@",testStr);

21.CoreText 排版 文字排版 文字样式 文字颜色 文字格式 下划线 字体

//创建要输出的字符串
NSString*longText=@"dsafdsafdsafdsfdsaf dsfdsf";
//创建AttributeString
NSMutableAttributedString*string=[[NSMutableAttributedString alloc]initWithString:longText ];
//创建字体以及字体大小

CTFontRef helvetica=CTFontCreateWithName(CFSTR("Helvetica"),14.0,NULL);
CTFontRef helveticaBold=CTFontCreateWithName(CFSTR("Helvetica-Bold"),14.0,NULL);
//添加字体目标字符串从下标0开始到字符串结尾
[string addAttribute:(id)kCTFontAttributeName value:(id)helvetica range:NSMakeRange(0, [string length])];
//添加字体目标字符串从下标0开始,截止到4个单位的长度
[string addAttribute:(id)kCTFontAttributeName value:(id)helveticaBold range:NSMakeRange(0, 4)];
//添加字体目标字符串从下标6开始,截止到5个单位长度
[string addAttribute:(id)kCTFontAttributeName value:(id)helveticaBold range:NSMakeRange(6, 5)];
//添加颜色,目标字符串从下标0开始,截止到4个单位长度
[string addAttribute:(id)kCTForegroundColorAttributeName value:(id)[UIColor blueColor].CGColor range:NSMakeRange(0, 4)];

//下划线功能
[NSDictionary dictionaryWithObjectsAndKeys:(id)sysUIFont,(id)kCTFontAttributeName,color,(id)kCTForegroundColorAttributeName,underline,(id)kCTUnderlineStyleAttributeName,nil];

22.右侧按钮

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc]
initWithTitle:@"查看正确答案"
style:UIBarButtonItemStylePlain
target:self
action:@selecto
    self.keys = array;
/*
//或者在自定义内容
NSArray*arr1=[[NSArray alloc]initWithObjects:@"One",@"Two",@"Three",nil ];
NSArray*arr2=[[NSArray alloc]initWithObjects:@"One1",@"Two1",@"Three1",nil ];

NSDictionary*dict=[[NSDictionary alloc]initWithObjectsAndKeys:arr1,@"Title1",arr2,@"Title2",nil];

*/

7).在最后添加如下代码
#pragma mark -
#pragma mark Table View Data Source Methods
//获取分区的数量 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [keys count];
}
//获取分区里的行的数量
//section为其中的一个分区
- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    NSString *key = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
    return [nameSection count];
}

//行的创建
- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 //获取第几分区
    NSUInteger section = [indexPath section];
 //获取行
    NSUInteger row = [indexPath row];
   
    NSString *key = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
   
    static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
                             SectionsTableIdentifier ];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier: SectionsTableIdentifier ] autorelease];
    }
   
    cell.textLabel.text = [nameSection objectAtIndex:row];
    return cell;
}
//为每个分区指定一个名称  现在的名称为key的值
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
    NSString *key = [keys objectAtIndex:section];
    return key;
}
//添加索引,索引的值为右侧的a--z
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    return keys;
}

15.自定义TableViewCell
-(void)makeSubCell:(UITableViewCell *)aCell withTitle:(NSString *)title
value:(NSString *)value
{
CGRect tRect = CGRectMake(20,5, 50, 40);
id lbl = [[UILabel alloc] initWithFrame:tRect]; //此处使用id定义任何控件对象
[lbl setText:title];
[lbl setBackgroundColor:[UIColor clearColor]];

CGRect tEdtRect = CGRectMake(50,15, 320, 40);
id edtPassword = [[UILabel alloc] initWithFrame:tEdtRect];
[edtPassword setText:value];
[edtPassword setBackgroundColor:[UIColor clearColor]];
//[edtPassword setKeyboardType:UIKeyboardTypeNumberPad];
// [edtPassword setSecureTextEntry:YES];
CGRect iEdtRect = CGRectMake(50,15, 320, 40);
id ima = [[UIImageView alloc] initWithFrame:tEdtRect];

[aCell addSubview:lbl];
[aCell addSubview:edtPassword];
[aCell addSubview:ima];

//release someone
[lbl release];
[edtPassword release];

}

//函数二 表格控制函数
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"Simple";

UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SimpleTableIdentifier] autorelease];
NSUInteger row = [indexPath row];

switch (row) {
case 0:
[self makeSubCell:cell withTitle:@"A:" value:@"password"];
break;
case 1:
[self makeSubCell:cell withTitle:@"B:" value:@"new password"];
break;
case 2:
[self makeSubCell:cell withTitle:@"C:" value:@"confirm password"];
break;
case 3:
[self makeSubCell:cell withTitle:@"D:" value:@"confirm password"];
break;
}
if (cell == nil)
{
NSLog(@"cell = nil");
}else
{
NSLog(@"cell <> nil");
}
return cell;
}

17.解析xml libxml 2.2
1.添加 libxml2 frameworks
   xcode中右击 "FrameWorks" ->Add->Add existing FWrameorks ,选择 "DyLibs",在其中选取libxml2 的dylib包,我选取的是 libxml2.2.7.3.dylib ,Add 即可
 
2.设置"Header Search Paths"
  在xcode中project->edit project settings->build 找到 "search paths",然后在Header Search Paths中添加
Xml代码  HYPERLINK "javascript:void()"
/usr/include/libxml2  
 这样添加也可以:
Xml代码  HYPERLINK "javascript:void()"
/Developer/Platforms/iPhoneOS.platform/Develope/SDKs/iPhoneOS4.0.sdk/usr/include/libxml2

18.多线程
// NSThread*t1=[[NSThread alloc]initWithTarget:self selector:@selector(jishi) object:nil ];
// [t1 start];
19记时器
NSTimer*myTimer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(jishi) userInfo:nil repeats:YES];

20.数据存储 NSUserDefaults

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSString stringWithFormat:@"%d",time] forKey:@"ESS_STUDY_TIME"];
[defaults synchronize];

//NSString *testStr = [defaults objectForKey:@"myTest"];
//NSLog(@"testStr is: %@",testStr);

21.CoreText 排版 文字排版 文字样式 文字颜色 文字格式 下划线 字体

//创建要输出的字符串
NSString*longText=@"dsafdsafdsafdsfdsaf dsfdsf";
//创建AttributeString
NSMutableAttributedString*string=[[NSMutableAttributedString alloc]initWithString:longText ];
//创建字体以及字体大小

CTFontRef helvetica=CTFontCreateWithName(CFSTR("Helvetica"),14.0,NULL);
CTFontRef helveticaBold=CTFontCreateWithName(CFSTR("Helvetica-Bold"),14.0,NULL);
//添加字体目标字符串从下标0开始到字符串结尾
[string addAttribute:(id)kCTFontAttributeName value:(id)helvetica range:NSMakeRange(0, [string length])];
//添加字体目标字符串从下标0开始,截止到4个单位的长度
[string addAttribute:(id)kCTFontAttributeName value:(id)helveticaBold range:NSMakeRange(0, 4)];
//添加字体目标字符串从下标6开始,截止到5个单位长度
[string addAttribute:(id)kCTFontAttributeName value:(id)helveticaBold range:NSMakeRange(6, 5)];
//添加颜色,目标字符串从下标0开始,截止到4个单位长度
[string addAttribute:(id)kCTForegroundColorAttributeName value:(id)[UIColor blueColor].CGColor range:NSMakeRange(0, 4)];

//下划线功能
[NSDictionary dictionaryWithObjectsAndKeys:(id)sysUIFont,(id)kCTFontAttributeName,color,(id)kCTForegroundColorAttributeName,underline,(id)kCTUnderlineStyleAttributeName,nil];

22.右侧按钮

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc]
initWithTitle:@"查看正确答案"
style:UIBarButtonItemStylePlain
target:self
action:@selector(seeAnswer)];
self.navigationItem.rightBarButtonItem = rightButton;

ipone 开发总结相关推荐

  1. iOS 应用程序的生命周期浅析

    做ipone开发有必要知道iPhone程序的生命周期,说白了就是点击应用图标启动程序到到退出程序,在这个运行的过程中底下的代码到底发生了什么,只有理解生命周期,有利于我们开发人员开发出更好的应用. 当 ...

  2. cocos2d-x 欢乐捕鱼游戏总结

    这几天一直都在做一个捕鱼游戏Demo,大概花掉了我快一个礼拜的时间.游戏主体是使用的cocos2d-x高级开发教程里面提供的小部分框架基本功能.然后自己加入所有的UI元素和玩法.变成了一个体验不错的捕 ...

  3. java知识体系介绍

    国内最牛七星级团队马士兵.高淇等11位十年开发经验专家录制 目 录 百战程序员Java1573题 2百战程序员介绍 3JavaSE编程基础 9第一章 初识Java 9阶段项目课程1 11第二章 数据类 ...

  4. iPone应用开发 UIView 常用属性和方法

    程序开发-uiview常用属性和方法">iPone应用程序开发 UIView常用属性和方法 常用属性 alpha 视图的透明度0.0f - 1.0f backgroundColor 视 ...

  5. 【iPone(iOS)相关开发】

    =====================以下iPhone(iOS)开发相关=============================== 001) 开发iOS应用软件的相关条件? 0> 基于I ...

  6. uniapp 开发 ipone底部安全区

    代码如下 <template><view :style="{height:height,background: bgco}" v-if="need&qu ...

  7. openresty开发系列29--openresty中发起http请求

    openresty开发系列29--openresty中发起http请求 有些场景是需要nginx在进行请求转发 用户浏览器请求url访问到nginx服务器,但此请求业务需要再次请求其他业务: 如用户请 ...

  8. 移动开发的分辨率问题

    这两天在做移动开发的准备,比较纠结于分辨率问题:iphone3的分辨率是320 X 480,iphone4直接翻了一倍640 X 960,而ipad1.ipad2的分辨率都是1024 X 768.如果 ...

  9. #java #web jsp开发入门(web应用概述、tomcat简介、编写步骤)

    #java #web jsp开发入门与编写步骤(web应用概述.tomcat简介.编写步骤) 目录 #java #web jsp开发入门与编写步骤(web应用概述.tomcat简介.编写步骤) 1.w ...

最新文章

  1. 利用.NET的XML序列化解决系统配置问题
  2. WebService大讲堂之Axis2(6):跨服务会话(Session)管理
  3. C++ Primer 5th笔记(chap 19 特殊工具与技术)控制内存分配
  4. 前端实现mac笔记本停靠栏效果
  5. QML 实现图片帧渐隐渐显轮播
  6. python中集合所用的reduce_Python中reduce函数和lambda表达式的学习
  7. 阿里云ECS服务器挂载磁盘
  8. 解决firefox字体发虚的问题
  9. 计算机应用设计的目的意义,高等教育自学考试计算机及应用专业+本科毕业设计(论文)的目的与要求...
  10. 关于郑州大学校园网锐捷客户端禁止热点分享,禁止多网卡的解决办法
  11. java实现车牌头像识别_LPR java车牌图像处理 输入一个车牌照片(不是整车的照片) - 下载 - 搜珍网...
  12. 蓝桥杯 算法提高 盾神与积木游戏
  13. Pandas(数据分析处理库)---讲解
  14. 关于爬取今日头条图片中的链接的提取(ajax)
  15. 【JavaSE】十二生肖带你走进枚举类
  16. Codeforces Contest 1138 problem B Circus —— 死亡1700,暴力
  17. 群里的初级工程师求助说,要采集采招数据,必须给他安排上
  18. python毕业设计作品基于django框架 校园二手书籍交易系统毕设成品(8)毕业设计论文模板
  19. 关于如何正确安装python的一些资源包和库的操作命令
  20. 广州软件学院C语言——实验3 最简单C程序设计1

热门文章

  1. Linux下使用C语言访问MySQL函数
  2. matlab中数值积分函数trapz的使用注意
  3. 我扒了37篇硅谷用户增长大神的blog,总结出这8点干货
  4. Dev-C++下载与安装(中文汉化版)
  5. 轮毂油封:车辆平稳高效运行的关键部件
  6. 2021年中国肥胖患病人数、减肥药主要品牌及市场规模分析[图]
  7. NameNode和SecondaryNameNode详解
  8. 华为汽车鸿蒙系统,华为的鸿蒙系统到底有多强大?预计最快明年在汽车上就能看到了...
  9. 安卓框架之二维码框架zxing的快速上手
  10. Python中字符串使用单引号、双引号标识和三引号标识,什么是三引号?什么情况下用哪种标识?