xcode库

提示类


布局类
switch portrait with landscape

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

 

    //from  portrait to the landscape

    if (UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) {

        conScrollview.contentSize=CGSizeMake(480*4, 320);

        int i;

        for (i=1; i<5; i++) {

            //create several imgs in the scrollview

            UIImageView *img=[[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat: @"%d.png",i]]]autorelease];

            //set every picture position on the scrollview

            img.frame=CGRectMake((i-1)*480, 0., 480,320 );

            //add the imgview into the scrollview

            [conScrollview addSubview:img];

            

        }

     //from landscape to portrait

    }else {

        conScrollview.contentSize=CGSizeMake(320*4, 480);

        

        int i;

        for (i=1; i<5; i++) {

            //create several imgs in the scrollview

            UIImageView *img=[[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat: @"%d.png",i]]]autorelease];

            //set every picture position on the scrollview

            img.frame=CGRectMake((i-1)*320, 0., 320,480 );

            //add the imgview into the scrollview

            [conScrollview addSubview:img];

            

        }

            

    }

}


locate the control

[self.view viewwithtag:n];



web类

input URL and load the webpage
h文件

IBOutlet UIWebView *vWebPage;

-(void)loadWebPage;

m文件

-(void)loadWebPage{

    NSString *s=@"http://www.baidu.com";

    NSURL *strURL=[NSURL URLWithString:s];

    NSURLRequest *urlReq=[NSURLRequest requestWithURL:strURL]; 

    

    [vWebPage loadRequest:urlReq];


多媒体类


animation

h文件

 

IBOutlet UIImageView *conImg;

m文件

 

    //create the obj of the imgs

    conImg.animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"img1.png"],

                                                [UIImage imageNamed:@"img2.png"],

                                                [UIImage imageNamed:@"img3.png"], nil];

 conImg.animationDuration=1.0;

 conImg.animationRepeatCount=2;

 [conImg startAnimating];

[self.view addSubview:conImg];//注:貌似这句话可有可无


zoom the picture

h文件

//uiscrollviewdelegate委托协议

 

IBOutlet UIImageView *conImg;

IBOutlet UIScrollView *conScrollView;


m文件

 

    //set scrollview controller as large as the img controller on the size  

    conScrollView.contentSize=conImg.image.size;

    conImg.frame=CGRectMake(0., 0., conImg.image.size.width, conImg.image.size.height);



//trigger this method

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

    return conImg;

}



//set the zoom property of the scale

paging the book
h文件
//uiscrollviewdelegate 挂载,同时在IB中也要对接,不需要用到uiimageview控件
IBOutlet UIScrollView *conScrollView;

//m文件

//set the contentsize of scrollview

    conScrollview.contentSize=CGSizeMake(320*4, 480);

   

    int i;

    for (i=1; i<5; i++) {

        //create several imgs in the scrollview

        UIImageView *img=[[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat: @"%d.png",i]]]autorelease];

        //set every picture position on the scrollview

        img.frame=CGRectMake((i-1)*320, 0., 320,480 );

        //add the imgview into the scrollview

        [conScrollview addSubview:img];

                          

    }


applying the gesture 

    //create and init the gesture

    UISwipeGestureRecognizer *gSwipe=[[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeAction:)]autorelease];//此处非常重要的一点是需要参数就需要加冒号!!!

    //specify the direction

    gSwipe.direction=UISwipeGestureRecognizerDirectionLeft;

    //add the gesture into view

    [self.view addGestureRecognizer:gSwipe];


  //在加载模态窗体的时候最重要的一点是,需要再建一个xib的viewcontroller,然后在present和dismiss的时候都要考虑需要不需要import各自的viewcontroller文件

 //在写方法的时候,有一个注意点就是形参需要加括号,参数名前面的*和参数名一个在括号里一个在括号外面

//specify the method

-(void) SwipeAction: (UISwipeGestureRecognizer *)g{

 

        //create a uiviewcontroller

        pictureViewController *pictureView=[[[pictureViewController alloc]initWithNibName:@"pictureViewController" bundle:nil]autorelease];

        //set the present style

        pictureView.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;

        //open the animation enable

        [self presentModalViewController:pictureView animated:YES];   

}


//dismissmodalviewcontroller

 

-(void) gSwipeRight : (UISwipeGestureRecognizer *)g{

    self.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;

    [self dismissModalViewControllerAnimated:YES];

}



文件操作类
//文件操作类,主要用到NSManager   NSFileHandle这两个类
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值