iOS笔记

July 27, 2016
作者:dengshuai_super
出处:http://blog.csdn.net/dengshuai_super/article/details/52050398
声明:转载请注明作者及出处。


✓   2015.6.4 周四

file’s owner以及outlet与连线的理解

file’s owner 可以看作是xib对应的类,比如view对应的xib文件的file‘s owner
对应的就是view controller的类。

我对file’s owner 的理解:xib文件附属于一个类,这个类就是xib属性栏中的custom Class,并且custom Class一般是控制器类A。而file’s owner相当于这个控制器类A。现在需要对控制器A中定义的类 和 xib中的形象化的控制器类B进行连接,只要从file’s owner 拖到对应的控制器B进行连接。这个过程相当对把A中的某个属性(一般都是定义的类IBOutlet)和B中的控件或者视图或者控制器对应起来。
而事件的连接的过程则相当于将B中的某个执行动作和A中的某个方法(IBAction)

view和viewController之间的对应关系,需要一个桥梁来进行连接(即,对于一个视图,他如何知道自己的界面的操作应该由谁来响应),这个桥梁就是File’s
Owner。

选中某个XIB的File’s Owner ,在Inspector中可以看到属性:File Name和Custom Class,该File’s Owner 就是用来绑定File Name中的xib文件和Custom Class中的ViewController的,在做了这个绑定之后,按住control键,拖动File‘s Owner 到xib中的某个控件的时候,就是Custom Class中定义的IBOutlet元素与xib中元素中进行连接的过程,同样,拖动“xib中的控件的动作”到File’s Owner的时候,就是将xib中该动作的响应与Custom Class中某个IBAction进行连接的过程。

xib文件本身可以看作是一个xml,app启动的时候会根据xml构造的xib对应的界面及其控件。

✓   2015.6.19周五

http://blog.csdn.net/q199109106q/article/details/8563438/

✓   2015.6.22周一

http://mobile.51cto.com/iphone-388248.htm

4、打开ViewController.m,找到addButton函数,添加以下代码:

    1.  - (IBAction)addButton:(id)sender { 
    2.      //动态添加一个按钮 
    3.      CGRect frame = CGRectMake(300, 300, 300, 50);  
    4.      UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];  
    5.      button.frame = frame; 
    6.      [button setTitle:@"新添加的动态按钮" forState: UIControlStateNormal];   
    7.      button.backgroundColor = [UIColor clearColor];   
    8.      button.tag = 2000; 
    9.      [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];   
    10.     [self.view addSubview:button];   
    11. } 

5、在addButton函数后边添加一个函数:

    1.  //这个是新按钮的响应函数 
    2.  -(IBAction) buttonClicked:(id)sender {   
    3.      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"  
    4.                                                      message:@"单击了动态按钮!"    
    5.                                                     delegate:self    
    6.                                            cancelButtonTitle:@"确定"   
    7.                                            otherButtonTitles:nil];   
    8.      [alert show]; 
    9.      [alert release]; 
    10. } 
    11. 

在深色背景下将状态条设置成白色:

在老版本的iOS中,状态栏永远都是白色风格。而在iOS 7中,我们可以修改每个view controller中状态栏的外观。通过UIStatusBarStyle常量可以指定状态栏的内容是暗色或亮色。默认情况下,状态栏的显示是暗色。也就是说,状态栏上的时间、电池指示器和Wi-Fi信号显示为暗色。如果导航栏中使用暗色为背景

-(UIStatusBarStyle)preferredStatusBarStyle 
{ 
    return UIStatusBarStyleLightContent; 
}

通过tag值获得相应对象

UITabBarItem *shouye = (UITabBarItem *)[self.view viewWithTag:100];

改变TabBarItem的选中时和未选中时的图片
UITabBarItem *ti1 = [tabBar.items objectAtIndex:0];
ti1.title = @”梦见”;

ti1.image = [[UIImage imageNamed:@"qr_tabbar_mine"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
ti1.selectedImage = [[UIImage imageNamed:@"qr_tabbar_mine_hl"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 

http://www.bkjia.com/IOSjc/872299.html
3.以上拖拽工作到此结束,下面要实现我们的业务逻辑和关联视图之间的关系,为了关联视图时能找到带有三个按钮的视图,我们需要设置一下该视图的StoryboardID,入下图

  4.下面来编写我们的代码,上面我们用到了TextField,我们需要处理键盘的回收事件,所以我们的ViewController要遵守UITextFiledDelegate协议,实现有关键盘的方法
    (1)遵守UITextFieldDelegate协议

#import <UIKit/UIKit.h>   
@interface ViewController : UIViewController<UITextFieldDelegate> 
@end

    (2)在ViewController.m中中进行回调注册和实现协议中相应的方法,代码如下:

-(BOOL) textFieldShouldReturn:(UITextField *)textField {     
[self.userName resignFirstResponder];     [self.password resignFirstResponder];    
return YES; 
}   
- (void)viewDidLoad {     
[super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.    self.userName.delegate = self;     self.password.delegate = self; 
- }

  5.处理完键盘的事儿,就该处理我们当登陆按钮点击时回调的事件了,首先在回调方法中获取TextFiled的值,由值的情况来实现是否进行页面间的切换。 在页面切换时我们得关联两个页面中的关系。

- (IBAction)tapButton:(id)sender {           
if ([username isEqualToString:@"admin"] && [password isEqualToString:@"admin"])     
{
//获取storyboard: 通过bundle根据storyboard的名字来获取我们的storyboard,         
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];    //由storyboard根据myView的storyBoardID来获取我们要切换的视图        
UIViewController *myView = [story instantiateViewControllerWithIdentifier:@"myView"];//由navigationController推向我们要推向的view         
[self.navigationController pushViewController:myView animated:YES];               
}   
}

 代码说明:关联两个View需要三部
1.获取storyboard: 通过bundle的名获取bundle, 在通过storyborad的名字来获取我们的storyboard;
2.在由storyboard获取storyboardID是myView的View;
3.执行由当前View推向我们获取到的myView;

使用storyboard,设置tab bar Item的选中图片(selected Image)
http://blog.csdn.net/sxh1234567/article/details/44984665

                                       9:16


这里写图片描述

http://www.cocoachina.com/ios/20141230/10800.html
快速兼容iPhone5s和6,6plus

✓   2015.6.23 周二
static NSString *CellIdentifier= @"CellIdentifier";

#define PLISTFILENAME @"SpeMerchantPList.plist"

#define PATH  [[NSBundle mainBundle]pathForResource:PLISTFILENAME ofType:nil]

- (void)viewDidLoad {
    [super viewDidLoad];
   // [_SpecialMerchantTableView setBackgroundColor:[UIColor grayColor]];//把背景色改为黑色背景
    _SpeMerchantInfoArray = [NSArray arrayWithContentsOfFile:PATH];

    [self.tableView registerClass:[UITableViewCell class]  forCellReuseIdentifier:CellIdentifier];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return [_SpeMerchantInfoArray count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    // Configure the cell...
    if ([_SpeMerchantInfoArray count]>0)
    {

        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(7, 7, 100, 70)];
        imageView.image = [UIImage imageNamed:_SpeMerchantInfoArray[indexPath.row][0]];
        [cell addSubview:imageView];

        UILabel *TitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(115, 8, 95, 21)];
        TitleLabel.text = _SpeMerchantInfoArray[indexPath.row][1];
        [cell addSubview:TitleLabel];

        UILabel *DateLabel = [[UILabel alloc]initWithFrame:CGRectMake(121, 39, 160, 17)];
        DateLabel.text = _SpeMerchantInfoArray[indexPath.row][2];
        DateLabel.backgroundColor = [UIColor clearColor];
        DateLabel.textColor = [UIColor grayColor];
        DateLabel.font = [UIFont fontWithName:@"STHeiti-Medium.ttc" size:5];
        [cell addSubview:DateLabel];

        UILabel *JuLiLabel = [[UILabel alloc]initWithFrame:CGRectMake(240, 7, 63, 21)];
        JuLiLabel.text = _SpeMerchantInfoArray[indexPath.row][3];
        [cell addSubview:JuLiLabel];

        UIButton *zuobiaoButton = [[UIButton alloc]initWithFrame:CGRectMake(215, 7, 20, 20)];
       // [zuobiaoButton.imageView setImage:[UIImage imageNamed:@"zaixiandaohang"] ];
        [zuobiaoButton setImage:[UIImage imageNamed:@"zaixiandaohang"] forState:UIControlStateNormal];
        [cell addSubview:zuobiaoButton];

        UIButton *moneyButton = [[UIButton alloc]initWithFrame:CGRectMake(303, 7, 20, 20)];
        //[moneyButton.imageView setImage:[UIImage imageNamed:@"caifu"] ];
        [moneyButton setImage:[UIImage imageNamed:@"caifu"] forState:UIControlStateNormal ];
        [cell addSubview:moneyButton];


    }


    return cell;
}
✓   2015.6.24 周三

http://www.cocoachina.com/bbs/read.php?tid-281373.html

//自定义按钮,文字在左,图片在右
HHButton *btn = [[HHButton alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];//宽100,高30只是最大的显示面积。 
[btn setTitle:@"山东省青岛市" forState:UIControlStateNormal]; 
[btn setImage:[UIImage imageNamed:@"小三角"  forState:UIControlStateNormal]; 


 [[UITabBar appearance] setSelectedImageTintColor:[UIColor orangeColor]];

init-初始化程序
viewDidLoad-加载视图
viewWillAppear-UIViewController对象的视图即将加入窗口时调用;
viewDidApper-UIViewController对象的视图已经加入到窗口时调用;viewWillDisappear-UIViewController对象的视图即将消失、被覆盖或是隐藏时调用;viewDidDisappear-UIViewController对象的视图已经消失、被覆盖或是隐藏时调用;didReceiveMemoryWarning - 内存不足时候调用这个

当利用ScrollView实现滚动页面时,初始化ScrollView时CGRectMake当width要设置成ScreenWidth,而它的ContentSize的宽度设置成实际内容所需要的宽度,例如有3张图片则设置成3倍图片的宽度。

http://www.cnblogs.com/woainilsr/archive/2012/03/28/2421881.html

length = (self.view.frame.size.width-40)/6;
    Scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, smallScroll.frame.origin.y+smallScroll.frame.size.height, screenWidth, length*1.8)];
    Scroll.bounces = NO;
    Scroll.backgroundColor=[UIColor whiteColor];
    Scroll.showsHorizontalScrollIndicator = NO;
    Scroll.pagingEnabled = YES;
    Scroll.delegate = self;
    Scroll.contentSize = CGSizeMake(self.view.frame.size.width*2, length*1.8);
    [scrollView addSubview:Scroll];

Scroll.contentSize = CGSizeMake(self.view.frame.size.width*buttonTitleArr.count/4, length*1.8);

设置pageControl:

    pageControl2 = [[UIPageControl alloc]initWithFrame:CGRectMake(screenWidth/2-35, Scroll.bounds.origin.y+Scroll.bounds.size.height+smallScroll.bounds.size.height-10, 70, 10)];
    pageControl2.numberOfPages = buttonTitleArr.count/4 ;
    pageControl2.currentPage = 0;
    pageControl2.currentPageIndicatorTintColor = [UIColor colorWithRed:255/255.0f green:91/255.0f blue:119/255.0f alpha:1];
    pageControl2.pageIndicatorTintColor = [UIColor grayColor];
    [pageControl2 addTarget:self action:@selector(btnPageControl2:) forControlEvents:UIControlEventValueChanged];
    pageControll2=YES;
    [scrollView addSubview:pageControl2];

    [self collectionView];
✓   2015.6.25 周四

http://www.cnblogs.com/top5/archive/2012/05/17/2506623.html

//下面代码实现进度轮的启动和停止:
- (void)viewDidLoad
{
    activity = [[UIActivityIndicatorViewalloc] initWithFrame:CGRectMake(0, 0, 30, 30)];//指定进度轮的大小
    [activitysetCenter:CGPointMake(160, 140)];//指定进度轮中心点
    [activitysetActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];//设置进度轮显示类型
    [self.viewaddSubview:activity];
    [superviewDidLoad];
}

//button点击所触发的方法。 启动或关闭进度轮。
- (IBAction)startOrStop:(id)sender{
    if([activityisAnimating]){
        [activitystopAnimating];
    }
    else
        [activitystartAnimating];
}

ios uiscrollview和 pagecontrol怎么结合使用
http://zhidao.baidu.com/link?url=Rngr26W9A3aO3C68RSmisJ1jCLqwJj_xiiifw4lZtiinChXiC__Y1-AAXcMFyRkBPMo8L_PDJShFNMgSqL42YUvRHwT6_Pepcmku0zF3bjq

@interface RootViewController : UIViewController<UIScrollViewDelegate>

{

    UIScrollView *_scrollView;

    NSMutableArray *slideImages;

    UIPageControl *_page;

}


@end
#import "RootViewController.h"


@interface RootViewController ()


@end


@implementation RootViewController


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


- (void)viewDidLoad

{

    [super viewDidLoad];



    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 20, 320, 240)];

    _scrollView.bounces = NO;

    _scrollView.pagingEnabled = YES;

    _scrollView.delegate = self;

    _scrollView.contentOffset = CGPointMake(320, 0);

    _scrollView.contentSize = CGSizeMake(1920,240);

    _scrollView.showsVerticalScrollIndicator =NO;

    _scrollView.showsHorizontalScrollIndicator = NO;

    _scrollView.userInteractionEnabled = YES;

    [self.view addSubview:_scrollView];

    [_scrollView release];



    slideImages = [[NSMutableArray alloc]initWithObjects:@"1.jpeg",@"2.jpg",@"3.jpeg",@"4.jpeg", nil];



    UIImageView *imageView = [[UIImageView alloc]

                              initWithImage:[UIImage imageNamed:[slideImages objectAtIndex:([slideImages count]-1)]]];

    imageView.frame = CGRectMake(0, 0, 320, 240);

    [_scrollView addSubview:imageView];

    [imageView release];



    for (int i = 0;i<[slideImages count];i++) {

        //loop this bit

        UIImageView *imageView = [[UIImageView alloc]

                                  initWithImage:[UIImage imageNamed:[slideImages objectAtIndex:i]]];

        imageView.frame = CGRectMake(320*i+320, 0, 320, 240);

        imageView.userInteractionEnabled = YES;

        [_scrollView addSubview:imageView];

        [imageView release];

    }



    imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[slideImages objectAtIndex:0]]];

    imageView.frame = CGRectMake(320*5, 0, 320, 240);

    [_scrollView addSubview:imageView];



    [imageView release];





    _page = [[UIPageControl alloc]initWithFrame:CGRectMake(240, 230, 70, 30)];

    _page.numberOfPages = 4;

    _page.currentPage = 0;



//    _page.backgroundColor = [UIColor grayColor];

    [_page addTarget:self action:@selector(pageAction) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:_page];

    [_page release];

// Do any additional setup after loading the view.

}



- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

{

    int currentPage = (_scrollView.contentOffset.x - _scrollView.frame.size.width

                             / ([slideImages count]+2)) / _scrollView.frame.size.width + 1;

    NSLog(@"%d",currentPage);

    if (currentPage==0) {

        [_scrollView scrollRectToVisible:CGRectMake(320*4, 0, 320, 240) animated:NO];

    }

    else if (currentPage==([slideImages count]+1)) {

            //如果是最后+1,也就是要开始循环的第一个

            [_scrollView scrollRectToVisible:CGRectMake(320, 0, 320, 240) animated:NO];

        }

}


- (void)scrollViewDidScroll:(UIScrollView *)sender

{

    int page = _scrollView.contentOffset.x/320-1;

    _page.currentPage = page;

}


-(void)pageAction

{

    int page = _page.currentPage;

    [_scrollView setContentOffset:CGPointMake(320 * (page+1), 0)];

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


- (void)dealloc {



    [slideImages release];

    [super dealloc];

}


@end
✓   2015.6.26 周五

.a文件是LINUX系统中的静态链接库文件。所谓静态链接是指把要调用的函数或者过程链接到可执行文件中,成为可执行文件的一部分。当多个程序都调用相同函数时,内存中就会存在这个函数的多个拷贝,这样就浪费了宝贵的内存资源。.so文件是共享库文件(动态链接)。动态链接所调用的函数代码并没有被拷贝到应用程序的可执行文件中去,而是仅仅在其中加入了所调用函数的描述信息(往往是一些重定位信息),仅当应用程序被装入内存开始运行时,在操作系统的管理下,才在应用程序与相应的.so之间建立链接关系。
.a文件是多个.o文件的组合。.o文件就是对象文件,里面包含的内容就是01这样的机器可执行的指令,当程序要执行时还需要进行链接(link).链接就是把多个.o文件链成一个可执行文件。

真机测试添加设备的步骤
http://my.oschina.net/u/1245365/blog/196420

CLLocationManager的例子
http://blog.csdn.net/pinklpig/article/details/7191347

想得到定点的信息,主要使用两个类,CLLocationManager, CLLocationManagerdelegate协议,

m文件内容如下
1、先实例化一个CLLocationManager,同时设置委托及精确度等。

CCLocationManager *manager = [[CLLocationManager alloc] init];//初始化定位器
[manager setDelegate: self];//设置代理
[manager setDesiredAccuracy: kCLLocationAccuracyBest];//设置精确度
[manager startUpdatingLocation];//开启位置更新

2、接着实现CLLocationMangerDelegate协议的两个方法就可以了:

//定位时候调用
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation ;

//定位出错时被调
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;

iphone练习之手势识别(双击、捏、旋转、拖动、划动、长按)UITapGestureRecognizer

运用scrollView时一定要注意他的frame是显示的区域,一般为屏幕宽和高,他的内容区域contentSize也就是实际滚动的区域要设置好。否则不能滚动。

//设置scrollView的区域
    scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [scrollView setContentSize:CGSizeMake(screenWidth, 2300)];
    scrollView.backgroundColor = [UIColor colorWithRed:234/255.0f green:234/255.0f blue:234/255.0f alpha:1];
✓   2015.6.27 周六
        _gouwucheButton=[[UIButton alloc]initWithFrame: CGRectMake(self.bounds.origin.x+self.bounds.size.width-_tupian.frame.size.width/2.8, _salePriceLabel.frame.origin.y ,_tupian.frame.size.width/3, _priceLabel.frame.size.height)];
        _gouwucheButton.layer.cornerRadius = 3.0;//设置圆角button
       // [_gouwucheButton setTintColor:[UIColor orangeColor]];
        [_gouwucheButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal ];
        //_gouwucheButton.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
        [_gouwucheButton setTitle:@"加入购物车" forState:UIControlStateNormal];
        //_gouwucheButton.titleLabel.text = @"加入购物车";
        _gouwucheButton.titleLabel.textColor = [UIColor orangeColor];
        _gouwucheButton.titleLabel.font =[UIFont systemFontOfSize:10];
        _gouwucheButton.layer.borderColor = [UIColor orangeColor].CGColor;//边框颜色,要为CGColor
        _gouwucheButton.layer.borderWidth = 1;//边框宽度
        [self addSubview:_gouwucheButton];

用main.storyboard为不同尺寸设备做适配
http://blog.csdn.net/liangliang103377/article/details/40082255

iOS7自动布局一
http://www.cocoachina.com/industry/20131203/7462.html

iOS7自动布局二
http://www.it165.net/pro/html/201409/22410.html

Xcode6中自动布局autolayout和sizeclass的使用
http://www.cocoachina.com/ios/20140915/9623.html

✓   2015.6.29 周一
 //设置价格
        //tempGoodView.priceLabel.backgroundColor = [UIColor blackColor];
        tempGoodView.priceLabel.text =[NSString stringWithFormat:@" ¥%@元",model2.price];
        // 根据priceLabel的字数设置他的宽度
        CGSize tempsize = [tempGoodView.priceLabel.text sizeWithFont:tempGoodView.priceLabel.font
                                                          constrainedToSize:tempGoodView.priceLabel.frame.size lineBreakMode:tempGoodView.priceLabel.lineBreakMode];

        tempGoodView.priceLabel.frame = CGRectMake(tempGoodView.priceLabel.frame.origin.x, tempGoodView.priceLabel.frame.origin.y, tempsize.width, tempsize.height);

        //设置打折之前价格
        //tempGoodView.salePriceLabel.backgroundColor =[UIColor blackColor];
        tempGoodView.salePriceLabel.frame = CGRectMake(tempGoodView.priceLabel.frame.origin.x+tempGoodView.priceLabel.frame.size.width, tempGoodView.salePriceLabel.frame.origin.y, tempGoodView.salePriceLabel.frame.size.width, tempGoodView.salePriceLabel.frame.size.height);
        //tempGoodView.salePriceLabel.textAlignment = NSTextAlignmentCenter;

        NSString *oldPrice = [NSString stringWithFormat:@"%@元",model2.YuanPrice];
        NSUInteger length2 = [oldPrice length];

//添加中间的删除线
        NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldPrice];
        [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length2)];
        [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor colorWithWhite:0.4 alpha:1] range:NSMakeRange(0, length2)];
        [tempGoodView.salePriceLabel setAttributedText:attri];
✓   2015.6.30 周二    请假


✓   2015.7.1   周三
UIButton* xiaoqubutton=[[UIButton alloc]initWithFrame:CGRectMake(screenWidth/2+7, 11, 85, 20)];
    xiaoqubutton.titleLabel.font =[UIFont systemFontOfSize:8];
    [xiaoqubutton.titleLabel setTextColor:[UIColor whiteColor]];

    xiaoqubutton.imageEdgeInsets = UIEdgeInsetsMake(1, 64, 0, 7);//设置三角小图标的位置
    [xiaoqubutton setImage:[UIImage imageNamed:@"sanjiao3"] forState:UIControlStateNormal];

    //xiaoqubutton.layer.borderColor = [UIColor orangeColor].CGColor;//边框颜色,要为CGColor
    //xiaoqubutton.layer.borderWidth = 1;//边框宽度
    xiaoqubutton.layer.cornerRadius = 5.0;
    xiaoqubutton.backgroundColor = [UIColor orangeColor];
✓   2015.7.2   周四

设置tabBarItem的图像时,图片为60x60像素,命名时用“名称+@2x”这样就可以很好的适应大小了

tabBarItem0.selectedImage = [[UIImage imageNamed:@"shouye01@2x"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    tabBarItem0.image =[[UIImage imageNamed:@"shouye02@2x"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem0.title=@"首页";

1.普通分页滑动

    myScrollView = [[UIScrollViewalloc]initWithFrame: CGRectMake(0,0,320,460)];
     [myScrollViewsetContentSize:CGSizeMake(pageWidth*3,460)];
    [myScrollViewsetBackgroundColor:[UIColorscrollViewTexturedBackgroundColor]];
    [myScrollViewsetPagingEnabled:YES];//当此属性设置为YES时,才能自动分页
    [self.viewaddSubview:myScrollView];


[image sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"1@2x"]];//placeholderImage是图片加载完毕显示之前显示的图像。起到缓冲的效果
✓   2015.7.3   周五

代理使用:http://blog.csdn.net/huifeidexin_1/article/details/7567731

@protocol MyDelegate
-(void)buyIphone:(NSString *)iphoneType money:(NSString *)money;

@end
@interface My : NSObject
{
    id<MyDelegate> deleage;
}
@property(assign,nonatomic)id<MyDelegate> delegate;
@end

代码中声明了一个协议 名叫Mydelegate,在其中有一个buyIphone方法,即一个委托项。当我要购买手机的时候只需要通过delegate 调用 BuyIphone方法即可.
如下:

-(void)willbuy
{
    [delegate buyIphone:@"iphone 4s" money:@"4888"];

}

我不必关心谁现实了这一委托,只要实现了这个委托的类,并且buyIphone是声明的委托中必须实现的方法,那么就一定能够得到结果.
例如:商人类实现了这一委托(用表示实现)

#import <Foundation/Foundation.h>
#import "My.h"
@interface Business : NSObject<MyDelegate>

@end
//然后在 @implementation Business 中调用 buyIphone方法#import "Business.h"

@implementation Business

-(void)buyIphone:(NSString *)iphoneType money:(NSString *)money
{
    NSLog(@"手机有货,这个价钱卖你了,发货中!!");
}
@end

如何完全自定义NavigationBar

NavigationBar是很常用的一个元素,所以常常需要进行自定义操作,而一种比较直观的方式就是,先定义一个类NavigationBar继承自 UINavigationBar,而这个NavigationBar的内部内容则是比较复杂的了,里面添加我们需要的所有的navigationBar 的样式,而且使得这些view的尺寸都是整个NavigationBar的尺寸,然后再进行内部view的构建就可以了,而需要进行切换的时候就进行这些view之间的显示和隐藏的切换就可以了,最好使用一些动画,前面的文中有提供动画流畅的保证方式,现在新建一个HomeNavigationController 继承自 UINavigationController,并且在这个类的实现中这样操作

@implementation HomeNavigationController
-(instancetype)init
{
    self = [super initWithNavigationBarClass:[Navigationbar class] toolbarClass:nil];
    if (self) {
        self.delegate = self;
    }
    return self;
}

这样的话就将HomeNavigationController的导航栏的样式进行了确定了。而为了能进行子控制器的导航栏的正确显示,最好在HomeNavigationController中声明一个

@protocol SecretPresentableViewController <NSObject>
@optional
- (void)willPresentWithNavigationBar:(Navigationbar *)navigationBar;
@end

而那些想要拥有这个导航栏的自控制器只需要实现协议就可以了,而NavigationBar中的多个view的左右按钮以及中间都可以完全的自定义了,而事件 的传递则使用block的方式,这里提供其中一个自定义view的h定义方式

@interface HomeNavigationView : UIView
@property(nonatomic, copy) void (^didTapComposeBlock)(void);
@property(nonatomic, copy) void (^didTapNotificationsBlock)(void);
@property(nonatomic, copy) void (^didTapChatBlock)(void);
@property(nonatomic, copy) void (^didTapScrollToTopBlock)(void);
@property(nonatomic, copy) void (^didTapNewThemeTopBlock)(void);
@property (nonatomic, strong) UILabel* titleLabel;
@property (nonatomic, strong) UIButton *tipsNewThemeBtn;
@property (nonatomic, strong) UIButton *unreadLeftV;
@end

而在m文件中只要对按钮添加监听就可以了,例子是

#pragma private
-(void)left:(id)sender
{
    if (_didTapNotificationsBlock) _didTapNotificationsBlock();

}
在拥有navigationBar 的控制器中对具体的block进行处理
navigationBar.homeNavigationView.didTapNotificationsBlock = ^{
        [self left:nil];
    };

而里面使用的这个left:方法则正是这个控制器中的具体的处理方法(push,modal,或者按钮的消失,lable的隐藏等等的点击相应等等),这样的话就实现了自定义bar的同时而且实现了bar和控制器之间的无缝衔接。更加方便的进行自定义的操作,但同时也可以完全实现系统提供bar的所有功能等等,而这个具体的实现过程很有可能就是apple自己内部的实现方式,因为apple很推荐我们使用block而这种bar和viewcontrol的传递消息的方式感觉这是最优秀的了。

✓   2015.7.4   周六

Swift基础--调用第三方OC项目
http://blog.csdn.net/jwzhangjie/article/details/40421629

✓   2015.7.6   周一
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag==1) {
        if (buttonIndex ==1) {
            AdViewController *ad = [[AdViewController alloc]init];
            ad.AdUrl = label.text;
            [self.navigationController pushViewController:ad animated:YES];
        }
    }
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

//webview中页面返回
-(void)back
{
    if (webView.canGoBack==YES) {
        [webView goBack];
    }
}




//添加索引
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
    if (tableView.tag==1) {
        return self.keysArray ;
    }else{
        return nil;
    }

}

//标题,区名,相当于键值
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (tableView.tag == 1) {
        return self.keysArray[section];
    }else{
        return nil;
    }

}


//    1、调用 自带mail
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];
//
//    2、调用 电话phone
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
//
//    3、调用 SMS
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
//
//    4、调用自带 浏览器 safari
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];

//订阅通知,当在BIDKeyboardDialViewController中新建联系人时通知我,我便执行重新加载数据方法
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getInfo:) name:@"updateData" object:nil];


//发送通知,通知通讯录增加了联系人,让他更新数据
    [[NSNotificationCenter defaultCenter]postNotificationName:@"updateData" object:nil ];

多线程
http://my.oschina.net/aofe/blog/270093
dispatch_async(dispatch_queue_create(“com.liujie.ZMLIVE”,NULL), ^{

    dispatch_async(dispatch_get_main_queue(), ^{
        //为商品区域整个页面加载数据
        [self setInfoForAllNormalGoodsView:GoodsAreaDic];
    });
});

UICollectionView实现分组显示
http://blog.csdn.net/zttjhm/article/details/37817719

UICollectionView实现自定义cell
http://www.cnblogs.com/ios8/p/iOS-UICollectionView.html

scrollView刷新
https://github.com/CoderMJLee/MJRefresh

✓   2015.7.7   周二

Xcode 6 LaunchImage 载入界面标准大小
LaunchImage启动页面大小
http://blog.it985.com/3335.html
这里写图片描述
iPhone Portrait iOS 8-Retina HD 5.5 (1242×2208) @3x
iPhone Portrait iOS 8-Retina HD 4.7 (750×1334) @2x
iPhone Portrait iOS 7,8-2x (640×960) @2x
iPhone Portrait iOS 7,8-Retina 4 (640×1136) @2x
iPhone Portrait iOS 5,6-1x (320×480) @1x
iPhone Portrait iOS 5,6-2x (640×960) @2x
iPhone Portrait iOS 5,6-Retina4 (640×1136) @2x

定位

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "GDataXMLNode.h"
@interface HomeViewController : UIViewController<CLLocationManagerDelegate>
@property(nonatomic,retain)CLLocationManager *locationManager;
@property (nonatomic,retain) UILabel * cityLabel;


@end
//判断定位操作是否被允许
    if([CLLocationManager locationServicesEnabled]) {
        self.locationManager = [[CLLocationManager alloc] init] ;
        self.locationManager.delegate = self;
        if ([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
            [_locationManager requestAlwaysAuthorization];
        }
        // 开始定位
        [self.locationManager startUpdatingLocation];

    }else {
        //提示用户无法进行定位操作
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:
                                  @"提示"message:@"定位不成功 ,请确认开启定位" delegate:nil cancelButtonTitle:@"取消"otherButtonTitles:@"确定",nil];
        [alertView show];
    }

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    //此处locations存储了持续更新的位置座标值,取最后一个值为最新位置,如果不想让其持续更新位置,则在此方法中获取到一个值之后让locationManager stopUpdatingLocation
    CLLocation *currentLocation = [locations lastObject];
    NSUserDefaults * user = [NSUserDefaults standardUserDefaults];
    [user setValue:[NSString stringWithFormat:@"%f",currentLocation.coordinate.latitude] forKey:@"lat"];
    [user setValue:[NSString stringWithFormat:@"%f",currentLocation.coordinate.longitude] forKey:@"lon"];
    NSLog(@"%f %f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
    //获取当前所在的城市名
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    //根据经纬度反向地理编译出地址信息
    [geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *array, NSError *error)
     {
         if (array.count >0)
         {
             CLPlacemark *placemark = [array objectAtIndex:0];
             //将获得的所有信息显示到label上

             //获取城市
             NSString *city = placemark.locality;
             NSLog(@"%@",placemark.locality);
             if (!city) {
                 //四大直辖市的城市信息无法通过locality获得,只能通过获取省份的方法来获得(如果city为空,则可知为直辖市)
                 city = placemark.administrativeArea;

             }

             _cityLabel.text= city;
             [user setValue:[NSString stringWithFormat:@"%@", _cityLabel.text]forKey:@"city"];
             [self importScheduleIntoServiceWithgetlon:[NSString stringWithFormat:@"%f",currentLocation.coordinate.longitude] andlat:[NSString stringWithFormat:@"%f",currentLocation.coordinate.latitude]];//根据经纬度执行
             NSLog(@"%@",city);

         }
         else if (error ==nil && [array count] ==0)
         {
             NSLog(@"No results were returned.");
         }
         else if (error !=nil)
         {
             NSLog(@"An error occurred = %@", error);

         }
     }];

    //系统会一直更新数据,直到选择停止更新,因为我们只需要获得一次经纬度即可,所以获取之后就停止更新
    [manager stopUpdatingLocation];
    //    [self.navigationController popViewControllerAnimated:YES];
}
- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error {
    if (error.code ==kCLErrorDenied) {
        // 提示用户出错原因,可按住Option键点击 KCLErrorDenied的查看更多出错信息,可打印error.code值查找原因所在
    }
}

判断网络是否连接正常
http://www.cnblogs.com/mrhgw/archive/2012/08/01/2617760.html

typedef enum {
    NotReachable = 0,
    ReachableViaWiFi,
    ReachableViaWWAN
} NetworkStatus;

我记得NotReachable是0吧,wifi是1,3g是2。
3g切换到wifi时 顺序为 201,
wifi切到3g时为102

MBProgressHUD的基本使用
http://blog.csdn.net/qjlhlh/article/details/8127436

再谈iOS 7的手势滑动返回功能

http://blog.csdn.net/jasonblog/article/details/28282147

iOS8自定义动画专场上手指南
http://www.360doc.com/content/15/0126/12/8772388_443794982.shtml

✓   2015.7.8   周三

第三方类库的使用
http://www.360doc.com/content/13/1211/08/14615320_336245146.shtml

http://www.open-open.com/lib/view/open1338688775312.html
因为iOS SDK相对比较底层,所以开发者就得受累多做一些体力活。不过幸运的是,有很多第三方的类库可以用来简化很多不必要的工作.经过作者团队的慎重讨论,他们 评选出了10款能够极大提高iOS开发效率的类库,根据原文作者的评价来看,基本上有了这10款工具,做iOS开发就真的跟泡Cocoa一样了。
MBProgressHUD(进度指示符库)
地址:https://github.com/jdg/MBProgressHUD
苹果的应用程序一般都会用一种优雅的,半透明的进度显示效果,不过这个API是不公开的,因此你要是用了,很可能被清除出AppStore。而 MBProgressHUD提供了一个替代方案,而且在用户角度上,实现的效果根本看不出和官方程序有什么差别。同时还提供了其他附加功能,比如虚拟进展 指示符,以及完成提示信息。整合到项目里也很容易,这里不细谈了。
ASIHttpRequest(HTTP Network库)
地址:http://allseeing-i.com/ASIHTTPRequest/
iPhone当然也有自己的HTTP Network API,那为什么要用ASIHttpRequest呢?因为官方的API简直跟话痨似的,太罗嗦了!ASIHttpRequest库极大的简化了网络通 信,提供更先进的工具,什么文件上传工具,重定向处理工具、验证工具、等等。只要你手头的东西跟HTTP有关,用这个绝对能让你感觉道生活有美好!先看一 段代码就体会到了。

    1   (void) loadAppDevMag    
    2   {    
    3      NSURL *url = [NSURL URLWithString:@"http://www.appdevmag.com"];    
    4      ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];    
    5      [request setDelegate:self];    
    6      [request startAsynchronous];    
    7   }    
    8       
    9   - (void)requestFinished:(ASIHTTPRequest *)request    
    10  {    
    11     // Use when fetching text data    
    12     NSString *responseString = [request responseString];    
    13  }   

JSON Framework(JSON支持)
地址:http://stig.github.com/json-framework/
如果你做的应用和网站服务器有交互,那就得用到JSON了。但事实上,iOS平台的原生类库根本就不支持JSON,这就略犀利了吧?不过JSON框 架满足了你的所有需求,包括一个解析器将JSON字符串解析成对象;以及一个生成器从对象生成字符串。这个库根本就是太流行了,JSON提过很多次了,具 体特点就不多讲了,所谓“一段代码胜千言”,下面用一段代码演示一下吧。

    1   // JSON string -> NSDictionary    
    2       
    3   NSString *jsonString = @"{\"foo\": \"bar\"}";    
    4       
    5   NSDictionary *dictionary = [jsonString JSONValue];    
    6       
    7   NSLog(@"Dictionary value for \"foo\" is \"%@\"", [dictionary objectForKey:@"foo"]);    
    8       
    9   // NSDictionary -> JSON string    
    10      
    11  NSString *newJsonString = [dictionary JSONRepresentation];   

Flurry(详尽的使用统计)

地址:http://www.flurry.com/product/analytics/index.html
这里写图片描述
通过Furry你可以得到应用的用户人数,用户活跃度,用户来源等统计信息。但是他最厉害的地方是,你可以追踪应用本身的事件和错误记录,所有这些 数据都会在一个类似Google Analytics的界面上显示,这样就很容易掌握用户的行为和出现的问题。当然,这个星球上很多统计工具,但是这款是作者个人比较推崇的解决方案。
RegexKitLite(正则表达式支持)
地址:http://regexkit.sourceforge.net/RegexKitLite/
正则表达式大家都知道。但是iPhone SDK居然当他不存在?这怎么能忍啊!果断用RegexKitLite。虽然叫的是Lite,但是功能很full。示例代码。

    1   // finds phone number in format nnn-nnn-nnnn    
    2   NSString *regEx = @"[0-9]{3}-[0-9]{3}-[0-9]{4}";    
    3   for(NSString *match in [textView.text componentsMatchedByRegex:regEx]) {    
    4       NSLog(@"Phone number is %@", match);    
    5   }  

Facebook iOS SDK(Facebook API类库)
这里写图片描述
地址:https://github.com/facebook/facebook-ios-sdk
大体来讲就是iPhone上的Facebook login,完全支持Facebook Graph API和the older REST api。如果你的应用跟Facebook有关,相信我,用这个吧。
SDWebImage(简化网络图片处理)
地址:https://github.com/rs/SDWebImage
用SDWebImage调用网站上的图片,跟本地调用内置在应用包里的图片一样简单。操作也很简单,举例说明
1 [imageView setImageWithURL:[NSURL URLWithString:
@"http://example.com/image.png"]];

类似的功能在Three20里也有,这个过会再说。相比而言,SDWebImage主要是提供一个小而精的简捷方便的解决方案
GData client(iPhone上所有Google相关服务的类库)
地址:http://code.google.com/p/gdata-objectivec-client/
名字就说明一切了。跟Google相关的,值得一提的是,这个项目很开放。有很多示例程序供下载。
CorePlot(2D图形绘图仪)
这里写图片描述
地址:http://code.google.com/p/core-plot/
CorePlot有很多解决方案将你的数据可视,同时也会提供各种迷人的图形效果,比如棒状图、饼状图、线状图等等,在他们网站上也提供了大量的范例图形,很多股票价格应用,游戏分数,个人财务管理都在用。
Three20(通用iOS库)
这里写图片描述
地址:https://github.com/facebook/three20
这里写图片描述
Three20类库是Facebook自己做的,大而全是他最大的特色。把他整合到已有的项目中可能得费点周折,不过如果一开始你就用上了Three20,尤其是牵扯到很多web相关的项目的时候,你就能深刻体会到神马叫给力了。
其他类库
无论是与Web交互的API、可视化数据、加载网上的图片或创建一个社会功能的应用程序,这里列出的库等功能使开发更容易。如果你是一个iOS开发人员,在你的下一个项目开始之前,你一定要检查有没有使用这些库。

http://blog.sina.com.cn/s/blog_6d01cce301016tof.html

KissXml——xml解析库
相关教程:http://www.iteye.com/topic/625849
http://sencho.blog.163.com/blog/static/83056228201151743110540/
很方便的一个xml解析器,支持Xpath查询。

skpsmtpmessage——Quick SMTP邮件发送
svn checkout http://skpsmtpmessage.googlecode.com/svn/trunk/ skpsmtpmessage-read-only
github: git clone https://github.com/kailoa/iphone-smtp.git
相关教程:http://disanji.net/2011/01/28/skpsmtpmessage-open-source-framework/
skpsmtpmessage 是由Skorpiostech, Inc.为我们带来的一个SMTP协议的开源实现,使用Objective-c 实现,iOS系统的项目可以直接调用

jsonframework——JSON支持
相关教程:http://blog.csdn.net/xiaoguan2008/article/details/6732683
它是一个开源框架,基于BSD协议发布。由于json-framework是开放源代码的,当你需要使用它时你只需将json的源代码加入到你的工程中。
ASIHttpRequest——HTTP Network库
ASIHttpRequest库极大的简化了网络通 信,提供更先进的工具,例如文件上传工具,重定向处理工具、验证工具、等等。
MBProgressHUD——进展指示符库
苹果的应用程序一般都会用一种优雅的,半透明的进度显示效果,不过这个API是不公开的,因此你要是用了,很可能被清除出AppStore。而 MBProgressHUD提供了一个替代方案,而且在用户角度上,实现的效果根本看不出和官方程序有什么差别。同时还提供了其他附加功能,比如虚拟进展 指示符,以及完成提示信息。整合到项目里也很容易,这里不细谈了。
zxing——二维码扫描库
支持条形码/二维码扫描的图形处理库,这是一个java库,在android上的功能比较完整。同时该库也支持ios,但只能支持二位条形码的扫描。
kal——iPhone日历控件
一个类似于ios系统默认日历开源日历库,支持添加事件,自定义日历样式等功能。
Facebook iOS SDK——Facebook API类库
大体来讲就是iPhone上的Facebook login,完全支持Facebook Graph API和the older REST api。
shareKit——分享库
相关demo:http://www.cocoachina.com/bbs/read.php?tid-71760.html
分享到开心,豆瓣,腾讯,新浪微博的api所用到的强大的分享库。
SDWebImage——简化网络图片处理
用SDWebImage调用网站上的图片,跟本地调用内置在应用包里的图片一样简单。操作也很简单。
GData client——iPhone上所有Google相关服务的类库
名字就说明一切了。跟Google相关的,值得一提的是,这个项目很开放。有很多示例程序供下载。
CorePlot——2D图形绘图仪
CorePlot有很多解决方案将你的数据可视。同时也会提供各种迷人的图形效果,比如棒状图、饼状图、线状图等等,在他们网站上也提供了大量的范例图形,很多股票价格应用,游戏分数,个人财务管理都在用。
Three20——类似于Facebook的优秀的UI库
Three20类库是Facebook自己做的,大而全是他最大的特色。把他整合到已有的项目中可能得费点周折,不过如果一开始你就用上了Three20,尤其是牵扯到很多web相关的项目的时候,你就能深刻体会到神马叫给力了。
FMDatabase——SQLite的Objective-C封装
是SQLite的C API对初学者来说实在太麻烦太琐碎,难度太高。FMDB说穿了其实只是把C API包装成简单易用的Objective-C类。对于SQLite初学者来说,大大减低了上手的难度。有了FMDB,写程式时只要专心在SQLite的语法上,而不用去理那堆有看没有懂的C API,实在是件快乐的事情。

IOS学习:常用第三方库(GDataXMLNode:xml解析库)
一、GDataXMLNode说明

GDataXMLNode是Google提供的用于XML数据处理的类集。该类集对libxml2–DOM处理方式进行了封装,能对较小或中等的xml文档进行读写操作且支持XPath语法。

使用方法:
1、获取GDataXMLNode.h/m文件,将GDataXMLNode.h/m文件添加到工程中
2、向工程中增加“libxml2.dylib”库
3、在工程的“Build Settings”页中找到“Header Search Path”项,添加/usr/include/libxml2”到路径中
4、添加“GDataXMLNode.h”文件到头文件中,如工程能编译通过,则说明GDataXMLNode添加成功

二、GDataXMLNode示例

示例:
[html] view plaincopy

1   <root>  
2        <name value="wusj"/>  
3        <age>24</age>  
4   </root>  

对此xml文件进行解析

[cpp] view plain copy

    1   NSString *xmlPath = [[NSBundlemainBundle] pathForResource:@"test"ofType:@"xml"];  
    2       NSString *xmlString = [NSStringstringWithContentsOfFile:xmlPath encoding:NSUTF8StringEncodingerror:nil];  
    3       GDataXMLDocument *xmlDoc = [[GDataXMLDocumentalloc] initWithXMLString:xmlString options:0error:nil];  
    4       GDataXMLElement *xmlEle = [xmlDoc rootElement];  
    5       NSArray *array = [xmlEle children];  
    6       NSLog(@"count : %d", [array count]);  
    7        
    8       for (int i = 0; i < [array count]; i++) {  
    9           GDataXMLElement *ele = [array objectAtIndex:i];  
    10            
    11          // 根据标签名判断  
    12          if ([[ele name] isEqualToString:@"name"]) {  
    13              // 读标签里面的属性  
    14              NSLog(@"name --> %@", [[ele attributeForName:@"value"] stringValue]);  
    15          } else {  
    16              // 直接读标签间的String  
    17              NSLog(@"age --> %@", [ele stringValue]);  
    18          }  
    19           
    20      }  
运行结果:
    ![这里写图片描述](https://img-blog.csdn.net/20160727234234579)


三、GDataXMLNode方法小结

 最终的数据读出都是在GDataXMLElement对象中读出的,以下方法均为GDataXMLElement类的方法
 1、name方法,取标签名 e.g name标签的名称“name”
 2、attributeForName: 取属性结点 再调stringValue即可取到属性值 e.g name标签中的value属性
 3、stringValue: 取标签间的字符串值  e.g: age间的24



✓   2015.7.9   周四

UICollectionView基础

http://www.cnblogs.com/wayne23/p/4013522.html

http://blog.csdn.net/eqera/article/details/8134986

✓   2015.7.10   周五
#import "CollectionHeader.h"

@implementation CollectionHeader

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        int screenWidth = [UIScreen mainScreen].bounds.size.width;
        _titleImageButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, screenWidth,50)];
//上面这句话开始写成了_titleImageButton = [[UIButton alloc]initWithFrame:self.frame];导致了header加载的位置错误❌,以后一定要注意子view的位置问题
        [self addSubview:_titleImageButton];
    }
    return self;
}
@end


//定义每个UICollectionView 的 margin
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{

    return UIEdgeInsetsMake(0, 5, 5, 5);//用于设置section中所有cell围起来占的view和cell所在CollectionView的边界在上,左,下,右四个方向上的距离。

}

 layout.minimumLineSpacing = paddingY;//这minimumLineSpacing设置cell纵向间距
    layout.minimumInteritemSpacing = 2;//这minimmInteritemSpacing设置cell横向间距


dispatch_sync(dispatch_queue_create("com.liujie.ZMLIVE",NULL), ^{

        dispatch_async(dispatch_get_main_queue(), ^{
        });
    });

推送
http://blog.csdn.net/shenjie12345678/article/details/41120637

http://www.cocoachina.com/industry/20130321/5862.html

百度iOS推送配置步骤:
在进入证书界面后,在左边的Identifiers选择中选定App IDs,点右上角加号创建Appid ,为远程推送服务创建的App ID一定要是全称,不能带有*
真机调试用的APNs SSL证书:要在哪台电脑上调试具有推送服务的App
这里写图片描述
发布程序用的APNs SSL证书:要在哪台电脑上发布具有推送服务的App
这里写图片描述
最终得到2个APNs SSL证书 APNs Development iOS:真机调试用的证书 APNs Production iOS:发布程序用的证书 
这里写图片描述
证书配置03 – 生成描述文件 描述文件的作用是用来描述 哪台设备要在哪台电脑上调试哪个程序
这里写图片描述

✓   2015.7.13   周一   请假


✓   2015.7.14   周二

百度推送
http://www.th7.cn/Program/IOS/201506/468069.shtml
http://samlee.gitcafe.io/jekyll/update/2015/06/11/samios.html

关于iOS Push Notification的响应问题
http://blog.sina.com.cn/s/blog_6fe6da830101mo4r.html

✓   2015.7.15   周三
#pragma -mark -functions

//获取字符串的宽度
-(float) widthForString:(NSString *)value fontSize:(float)fontSize andHeight:(float)height
{
    CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(CGFLOAT_MAX, height) lineBreakMode:NSLineBreakByWordWrapping];//此处的换行类型(lineBreakMode)可根据自己的实际情况进行设置
    return sizeToFit.width;
}
//获得字符串的高度
-(float) heightForString:(NSString *)value fontSize:(float)fontSize andWidth:(float)width
{
    CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByCharWrapping];//此处的换行类型(lineBreakMode)可根据自己的实际情况进行设置
    return sizeToFit.height;
}

scrollView属性
http://blog.csdn.net/aaajj/article/details/6872038
IOS中scrollsToTop问题小结
http://blog.csdn.net/enuola/article/details/32331933

XCode的 Stack Trace,调试时抛出异常,定位到某一行代码
http://blog.csdn.net/enuola/article/details/17761017

全面理解iOS开发中的Scroll View
http://mobile.51cto.com/hot-430409.htm

  我们有一个拖动时frame不断改变的视 图。这达到了相同的效果,对吗?如果我拖动我的手指到右边,那么拖动的同时我增大视图的origin.x,瞧,这货就是scroll view。
    当你设置它的contentOffset属性时:它改变scroll view.bounds的origin。事实上,contentOffset甚至不是实际存在的。代码看起来像这样:
    1   - (void)setContentOffset:(CGPoint)offset  
    2   {  
    3       CGRect bounds = [self bounds];  
    4       bounds.origin = offset;  
    5       [self setBounds:bounds];  
    6   }
    scroll view的content size并不会改变其bounds的任何东西,所以这并不会影响scroll view如何组合自己的子视图。反而,content size定义了可滚动区域。scroll view的默认content size为{w:0,h:0}。既然没有可滚动区域,用户是不可以滚动的,但是scroll view仍然会显示其bounds范围内所有的子视图。

当content size设置为比bounds大的时候,用户就可以滚动视图了。你可以认为scroll view的bounds为可滚动区域上的一个窗口
用Content Insets对窗口稍作调整
contentInset属性可以改变content offset的最大和最小值,这样便可以滚动出可滚动区域。它的类型为UIEdgeInsets,包含四个值: {top,left,bottom,right}。当你引进一个inset时,你改变了content offset的范围。比如,设置content inset顶部值为10,则允许content offset的y值达到10。这介绍了可滚动区域周围的填充。
如果你通过滚动足够多的距离初始化pull-to-refresh机制,因为table view设置了content inset,这将允许content offset将refresh control弹回到可滚动区域。当刷新动作被初始化时,content inset已经被校正过,所以content offset的最小值包含了完整的refresh control。当刷新完成后,content inset恢复正常,content offset也跟着适应大小,这里并不需要为content size做数学计算。(这里可能比较难理解,建议看看EGOTableViewPullRefresh这样的类库就应该明白了)
如何在自己的代码中使用content inset?当键盘在屏幕上时,有一个很好的用途:你想要设置一个紧贴屏幕的用户界面。当键盘出现在屏幕上时,你损失了几百个像素的空间,键盘下面的东西全都被挡住了。
现在,scroll view的bounds并没有改变,content size也并没有改变(也不需要改变)。但是用户不能滚动scroll view。考虑一下之前一个公式:content offset的最大值并不同于content size和bounds的大小。如果他们相等,现在content offset的最大值是{x:0,y:0}.
现在开始出绝招,将界面放入一个scroll view。scroll view的content size仍然和scroll view的bounds一样大。当键盘出现在屏幕上时,你设置content inset的底部等于键盘的高度。

- (void)scrollViewDidScroll:(UIScrollView *)scrollView1
{
    if ([scrollView1.restorationIdentifier isEqualToString:@"scrollView"])
    {
        NSLog(@"执行");
        if (scrollView1.contentOffset.y>3000) {
            NSLog(@"执行了");
            if (isFirstTopButton) {
                isFirstTopButton = NO;
                [self.view addSubview:topButton];
                NSLog(@"%lf    %lf",scrollView1.contentOffset.x,scrollView1.contentOffset.y);
            }
        }else{
            isFirstTopButton = YES;
            [topButton removeFromSuperview];
        }
    }
}
-(void)tapTopButton:(UIButton *)button
{
    //scrollView.contentOffset =CGPointMake(0, 0);
    //点击回到顶部按钮,滚回到屏幕开始位置。
    [scrollView scrollRectToVisible:CGRectMake(0, 0, screenWidth, screenHeight) animated:YES];
}
✓   2015.7.16   周四

分类推送

 NSMutableSet *tags = [[NSMutableSet alloc]init];//初始化tags、
if ([stringData isEqualToString: @"1"]) {
                 xiaoqu.text=@" 河北师大";
                 [self setXiaoquButtonSize];
                 SchoolId=@"1";
                 [tags addObject:SchoolId];
                 [APService setTags:tags callbackSelector:@selector(tagsAliasCallback:tags:alias:) object:self];// 参数object是实现//tag返回的回调函数
- (void)tagsAliasCallback:(int)iResCode tags:(NSSet*)tags alias:(NSString*)alias {
    NSLog(@"rescode: %d, \ntags: %@, \nalias: %@\n", iResCode, tags , alias);
}

iOSApp发布流程
http://www.macfans.org/thread-2370-1-1.html

iOS版本更新的App提交审核发布流程
http://www.2cto.com/kf/201502/378698.html

发布流程:把App Id准备好了以后,在此Appid里面将pushNotification用的开发推送证书和发布推送证书弄好,弄证书的时候需要在钥匙串请求request,request需要填开发者账号的邮箱。然后弄发布证书,发布证书要对应Appid,然后弄发布配置文件。
弄好了之后在Xcode中target和project中全都对应好发布证书还有配置文件。然后在edit scheme中将Build configuration改为release(这一步貌似不是必须的)。然后将真机拔掉,显示iOS service,在product选项中选择Archive(中文:档案),然后没错误进入Archives界面,点击Submit,如果没错误就成功。(错误通常是账户出现问题,解决方法:将没用的账户删了试试),之前在iTunes Connect中已经填的只剩构建版本了,刷新一下发现有了。提交并审核就可以了。

http://jingyan.baidu.com/article/f25ef25477db8b482d1b8252.html

✓   2015.7.20   周一
//给tableView添加headerView
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView1;
    if(section==0) {
        headerView1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenWidth, 50)];
        [headerView1 setBackgroundColor:[UIColor orangeColor]];
        return headerView1;
    }
    return headerView1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 50;
}
✓   2015.7.22   周三


✓   2015.7.23   周四

第三方库关于GridView实现网格视图

✓   2015.7.24   周五

【译】NSURLRequest的官方文档
http://blog.sina.com.cn/s/blog_717fba110101dqzp.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章