Last active
August 29, 2015 14:06
-
-
Save shoheiyokoyama/e053ed2c847aeb75dca4 to your computer and use it in GitHub Desktop.
my FirstApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "ViewController.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
//_imageArrayの初期化 | |
_imageArray = @[@"j1.jpeg", @"j2.jpeg", @"j3.jpeg", @"j4.jpeg",@"5.jpeg",@"6.jpeg",@"7.jpeg"]; | |
[portScrollView setContentSize:CGSizeMake(640,460)]; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (void) touchesBegan:(NSSet *) touches withEvent: (UIEvent *) event | |
{ | |
UITouch * touchedObj = [[event allTouches] anyObject]; | |
if (touchedObj.view.tag ==_imageView.tag) { | |
NSLog(@"imageViewがタップされた!"); | |
if(_imageArray.count == _imageArraySelectedIndex + 1) { | |
//_imageArray.count == _imageArraySelectedIndex + 1→配列の終端が表示されている時 | |
_imageArraySelectedIndex = 0; | |
} | |
else { | |
//配列の終端以外が表示されている時は_imageArraySelectedIndexをインクリメント | |
_imageArraySelectedIndex++; | |
} | |
NSLog(@"_imageArraySelectedIndex = %d, currentImage=%@", _imageArraySelectedIndex, _imageArray[_imageArraySelectedIndex]); | |
//_imageArraySelectedIndexに対応するイメージを_imageView.imageにセット | |
_imageView.image = [UIImage imageNamed:_imageArray[_imageArraySelectedIndex]]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment