IOS_3 _ Image Browsing
BeyondViewController. h
//// BeyondViewController. h // 03 _ Image Browsing /// Created by beyond on 14-7-22. // Copyright (c) 2014 com. beyond. all rights reserved. // # import
@ Interface BeyondViewController: UIViewController @ property (weak, nonatomic) IBOutlet UILabel * pageNoLabel; @ property (weak, nonatomic) IBOutlet UIImageView * pictureView; @ property (weak, nonatomic) IBOutlet UILabel * descriptionLabel; @ property (weak, nonatomic) IBOutlet UIView * viewSetting;-(IBAction) handle :( UISlider *) sender;-(IBAction) setting :( UIButton *) sender; // switch-(IBAction) switchClick :( UISwitch *) sender; // image size scaling-(IBAction) sliderScaleValueChanged :( UISlider *) sender; @ end
BeyondViewController. m
//// BeyondViewController. m // 03 _ Image Browsing /// Created by beyond on 14-7-22. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "BeyondViewController. h "@ interface BeyondViewController () {// load plist from mainBundle and return the array NSArray * _ descArray;} @ end @ implementation BeyondViewController-(void) viewDidLoad {[super viewDidLoad]; // load plist from mainBundle, return the array, and load it only once. // code of the sg_bundle template, 1, and obtain. the main package of the app; 2. The main package is returned. Full path NSBundle * mainBundle = [NSBundle mainBundle]; NSString * fullPath = [mainBundle pathForResource: @ "descs. plist "ofType: nil]; // member variable remember, because _ descArray = [NSArray arrayWithContentsOfFile: fullPath] is used in other methods of slideValueChanged; // _ descriptionLabel. text = _ descArray [0];}-(IBAction) slideValueChanged :( UISlider *) sender {NSLog (@ "% d", (int) sender. value); // The image name ranges from 0 ~ 15, corresponding slide minimum value 0 maximum value 15 int pageNo = (int) sender. value; // 1. NSString * imageName = [NSString stringWithFormat: @ "d.png", pageNo]; _ pictureView. image = [UIImage imageNamed: imageName]; // 2, control the title display _ pageNoLabel. text = [NSString stringWithFormat: @ "% d/16", (pageNo + 1)]; // 3, control description show plist in simulator full path // Users/beyond/Library/Developer/Xcode/DerivedData/03 _ picture browse-cwowmkgqqqqmfcfxckpaqtzykyus/Build/Product S/Debug-iphonesimulator/03 _ Image Browsing. app/descs. plist // Users/beyond/Library/Application Support/iPhone Simulator/7.1/Applications/02291F09-5446-40E2-82AE-18B6D039D88A/03 _ Image Browsing. app/descs. plist // NSString * descPlistFullPath = [[NSBundle mainBundle] pathForResource: @ "descs. plist "ofType: nil]; // _ descriptionLabel. text = [_ descArray objectAtIndex: pageNo]; _ descriptionLabel. text = _ descArray [pageNo];} # HPA Gma mark-settings: 1, night mode; 2, image scaling-(IBAction) setting :( UIButton *) sender {// class method of UIView to achieve animation effect (start animation) [UIView beginAnimations: nil context: nil]; // The default animation duration is 0.2 [UIView setAnimationDuration: 1]; int winHeight = self. view. bounds. size. height; CGFloat targetY = _ viewSetting. frame. origin. y = winHeight? (WinHeight-self.viewSetting.frame.size.height): winHeight; // the following three steps are the OC standard code, because OC does not allow direct repair of the value of the members of the struct attribute in the object, the temporary struct variable CGRect frame = self. viewSetting. frame; frame. origin. y = targetY; self. viewSetting. frame = frame; // The class method of UIView to achieve the animation effect (end animation) [UIView commitAnimations];}-(IBAction) switchClick :( UISwitch *) sender {if (sender. isOn) {self. view. backgroundColor = [UIColor darkGrayColor];} else {self. view. backgroundColor = [UIColor whiteColor] ;}}- (IBAction) sliderScaleValueChanged :( UISlider *) sender {// class method of UIView to achieve animation effect (start animation) [UIView beginAnimations: nil context: nil]; // The default animation duration is 0.2 [UIView setAnimationDuration: 1]; self. pictureView. transform = CGAffineTransformMakeScale (sender. value, sender. value); // The class method of UIView to achieve the animation effect (end animation) [UIView commitAnimations];} @ end