IOS ui_ Albums

Source: Internet
Author: User

////MAINVIEWCONTROLLER.M//albums////Created by Dllo on 15/8/6.//Copyright (c) 2015 Zhozhicheng. All rights reserved.//#import "MainViewController.h" #import "SecondViewController.h"  @interface mainviewcontroller ()//Create an array to store the image@property(nonatomic, retain)Nsmutablearray*arr;@end @implementation mainviewcontroller -(void) dealloc{[_arr release]; [SuperDealloc];} - (void) Viewdidload {[SuperViewdidload];additional setup after loading the view.    //Album Directory interface, first changed to opaque     Self. Navigationcontroller. Navigationbar. Translucent=NO; Self. View. BackgroundColor=[UicolorOrangecolor];//Set title     Self. Navigationitem. Title[Email protected]"Albums";//Initialize array     Self. Arr= [[NsmutablearrayALLOC] init];//Seven views     for(inti =1; I <8; i++) {NSString*imagename=[NSStringstringwithformat:@"H%d.jpeg", I];UIImage*image=[UIImageImagenamed:imagename]; [ Self. ArrAddobject:image]; }//Create seven button     for(inti =0; I <3; i++) { for(intj =0; J <3; J + +) {if(3* i + J <7) {UIButton*button = [UIButtonButtonwithtype:uibuttontypecustom]; button. Tag=3* i + j +1; button. Frame=cgrectmake (J * -+ -I -+ -, -, -); [ Self. ViewAddsubview:button]; button. Layer. BorderWidth=1;//Put the picture on the corresponding button[Button setimage: (UIImage*) Self. Arr[3* i + j] forstate:uicontrolstatenormal]; [Button AddTarget: SelfAction@selector(click:) forcontrolevents:uicontroleventtouchupinside]; }        }    }}-(void) Click: (UIButton*) button{//Click to skip to next pageSecondviewcontroller *secvc=[[secondviewcontroller alloc] init]; [ Self. NavigationcontrollerPUSHVIEWCONTROLLER:SECVC Animated:YES]; [SECVC release];//Pass a number valueSecvc. number=button. Tag-1;} - (void) Didreceivememorywarning {[SuperDidreceivememorywarning];//Dispose of any resources, can be recreated.}/ * #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before navigation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using    [Segue Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end
////  SecondViewController.h//  相册////  Created by dllo on 15/8/6.//  Copyright (c) 2015年 zhozhicheng. All rights reserved.//#import <UIKit/UIKit.h>@interface SecondViewController : UIViewController@property(nonatomic,assign)NSInteger number;@end
////SECONDVIEWCONTROLLER.M//albums////Created by Dllo on 15/8/6.//Copyright (c) 2015 Zhozhicheng. All rights reserved.//#import "SecondViewController.h" //Define two macros, wide ' high#define WIDTH Self.view.frame.size.width#define HEIGHT Self.view.frame.size.height @interface secondviewcontroller () <uiscrollviewdelegate>@property(nonatomic, retain)Uiscrollview*scrollview;@end @implementation secondviewcontroller -(void) dealloc{[_scrollview release]; [SuperDealloc];} - (void) Viewdidload {[SuperViewdidload];additional setup after loading the view.    //Create a scrolling page     Self. ScrollView=[[UiscrollviewAlloc] initWithFrame: Self. View. Frame]; [ Self. ViewAddsubview: Self. ScrollView]; [_scrollview release];//Let view scroll up properties, scroll range    //-100 is for the following scrolling dots     Self. ScrollView. Contentsize=cgsizemake (7* WIDTH, HEIGHT- -);//Scroll by page     Self. ScrollView. pagingenabled=YES;//scrolling pictures     for(inti =1; I <8; i++) {NSString*imagename =[NSStringstringwithformat:@"H%d.jpeg", I];//Create a scrolling seven views        Uiimageview*imageview=[[UiimageviewAlloc] initwithimage:[UIImageImagenamed:imagename]];//Set the starting position of the pictureImageView. Frame=cgrectmake (i * width-width,0, WIDTH, height- -); [ Self. ScrollViewAddsubview:imageview];    [ImageView release]; }//Off boundary rebound effect     Self. ScrollView. Bounces=NO;//Close scroll bar     Self. ScrollView. Showshorizontalscrollindicator=NO; Self. ScrollView. Showsverticalscrollindicator=NO;//Set up agents     Self. ScrollView. Delegate= Self;//Create dotsUipagecontrol *page=[[uipagecontrol Alloc] Initwithframe:cgrectmake ( -,580, $, +)]; Page. BackgroundColor=[UicolorWhitecolor]; [ Self. ViewAddsubview:page]; [Page release];//number of dotsPage. Numberofpages=7;//DOT colorPage. Pageindicatortintcolor=[UicolorCyancolor];//Color of selected pointsPage. Currentpageindicatortintcolor=[UicolorYellowcolor]; Page. Tag= +;//Show page number in the first sheet     Self. ScrollView. Contentoffset=cgpointmake (WIDTH * Self. number,0);NSString*str=[NSStringstringwithformat:@"§%ld", Self. number+1]; Self. Navigationitem. Title=str;}//Point as the picture scrolls-(void) Scrollviewdidscroll: (Uiscrollview*) scrollview{Uipagecontrol *page= (Uipagecontrol *) [ Self. ViewViewwithtag: +]; Page. CurrentPage= Self. ScrollView. Contentoffset. x/WIDTH;NSString*str=[NSStringstringwithformat:@"§%ld", page. CurrentPage+1]; Self. Navigationitem. Title=str;} - (void) Didreceivememorywarning {[SuperDidreceivememorywarning];//Dispose of any resources, can be recreated.}/ * #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before navigation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using    [Segue Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end! [Write a description of the picture here] (http://img.blog.csdn.net/20150810083852590)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

IOS ui_ Albums

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.