Skip to content

Commit 9639293

Browse files
committed
new sample
1 parent f201c88 commit 9639293

29 files changed

+1455
-0
lines changed

ImageViewTap/ImageViewTap.xcodeproj/project.pbxproj

+353
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIconFile</key>
12+
<string></string>
13+
<key>CFBundleIdentifier</key>
14+
<string>jp.lakesoft.${PRODUCT_NAME:rfc1034identifier}</string>
15+
<key>CFBundleInfoDictionaryVersion</key>
16+
<string>6.0</string>
17+
<key>CFBundleName</key>
18+
<string>${PRODUCT_NAME}</string>
19+
<key>CFBundlePackageType</key>
20+
<string>APPL</string>
21+
<key>CFBundleShortVersionString</key>
22+
<string>1.0</string>
23+
<key>CFBundleSignature</key>
24+
<string>????</string>
25+
<key>CFBundleVersion</key>
26+
<string>1.0</string>
27+
<key>LSRequiresIPhoneOS</key>
28+
<true/>
29+
<key>NSMainNibFile</key>
30+
<string>MainWindow</string>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
</dict>
38+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Prefix header for all source files of the 'ImageViewTap' target in the 'ImageViewTap' project
3+
//
4+
5+
#import <Availability.h>
6+
7+
#ifndef __IPHONE_3_0
8+
#warning "This project uses features only available in iPhone SDK 3.0 and later."
9+
#endif
10+
11+
#ifdef __OBJC__
12+
#import <UIKit/UIKit.h>
13+
#import <Foundation/Foundation.h>
14+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// ImageViewTapAppDelegate.h
3+
// ImageViewTap
4+
//
5+
// Created by Hiroshi Hashiguchi on 11/06/21.
6+
// Copyright 2011 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class ImageViewTapViewController;
12+
13+
@interface ImageViewTapAppDelegate : NSObject <UIApplicationDelegate> {
14+
15+
}
16+
17+
@property (nonatomic, retain) IBOutlet UIWindow *window;
18+
19+
@property (nonatomic, retain) IBOutlet ImageViewTapViewController *viewController;
20+
21+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//
2+
// ImageViewTapAppDelegate.m
3+
// ImageViewTap
4+
//
5+
// Created by Hiroshi Hashiguchi on 11/06/21.
6+
// Copyright 2011 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "ImageViewTapAppDelegate.h"
10+
11+
#import "ImageViewTapViewController.h"
12+
13+
@implementation ImageViewTapAppDelegate
14+
15+
16+
@synthesize window=_window;
17+
18+
@synthesize viewController=_viewController;
19+
20+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
21+
{
22+
// Override point for customization after application launch.
23+
24+
self.window.rootViewController = self.viewController;
25+
[self.window makeKeyAndVisible];
26+
return YES;
27+
}
28+
29+
- (void)applicationWillResignActive:(UIApplication *)application
30+
{
31+
/*
32+
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
33+
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
34+
*/
35+
}
36+
37+
- (void)applicationDidEnterBackground:(UIApplication *)application
38+
{
39+
/*
40+
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
41+
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
42+
*/
43+
}
44+
45+
- (void)applicationWillEnterForeground:(UIApplication *)application
46+
{
47+
/*
48+
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
49+
*/
50+
}
51+
52+
- (void)applicationDidBecomeActive:(UIApplication *)application
53+
{
54+
/*
55+
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
56+
*/
57+
}
58+
59+
- (void)applicationWillTerminate:(UIApplication *)application
60+
{
61+
/*
62+
Called when the application is about to terminate.
63+
Save data if appropriate.
64+
See also applicationDidEnterBackground:.
65+
*/
66+
}
67+
68+
- (void)dealloc
69+
{
70+
[_window release];
71+
[_viewController release];
72+
[super dealloc];
73+
}
74+
75+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// ImageViewTapViewController.h
3+
// ImageViewTap
4+
//
5+
// Created by Hiroshi Hashiguchi on 11/06/21.
6+
// Copyright 2011 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class ThumbnailView;
12+
@interface ImageViewTapViewController : UIViewController {
13+
14+
UIScrollView *scrollView;
15+
ThumbnailView *thumnailView;
16+
UIImageView *imageView;
17+
}
18+
@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;
19+
@property (nonatomic, retain) IBOutlet ThumbnailView *thumnailView;
20+
@property (nonatomic, retain) IBOutlet UIImageView *imageView;
21+
22+
- (void)touchedAtIndex:(NSInteger)index;
23+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//
2+
// ImageViewTapViewController.m
3+
// ImageViewTap
4+
//
5+
// Created by Hiroshi Hashiguchi on 11/06/21.
6+
// Copyright 2011 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "ImageViewTapViewController.h"
10+
#import "ThumbnailView.h"
11+
12+
@implementation ImageViewTapViewController
13+
@synthesize scrollView;
14+
@synthesize thumnailView;
15+
@synthesize imageView;
16+
17+
- (void)dealloc
18+
{
19+
[scrollView release];
20+
[thumnailView release];
21+
[imageView release];
22+
[super dealloc];
23+
}
24+
25+
- (void)didReceiveMemoryWarning
26+
{
27+
// Releases the view if it doesn't have a superview.
28+
[super didReceiveMemoryWarning];
29+
30+
// Release any cached data, images, etc that aren't in use.
31+
}
32+
33+
#pragma mark - View lifecycle
34+
35+
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
36+
- (void)viewDidLoad
37+
{
38+
[super viewDidLoad];
39+
40+
NSMutableArray* imageList = [NSMutableArray array];
41+
for (int i=0; i < 8; i++) {
42+
UIImage* image = [UIImage imageNamed:
43+
[NSString stringWithFormat:@"image%02ds.jpg", i+1]];
44+
[imageList addObject:image];
45+
}
46+
self.thumnailView.imageList = imageList;
47+
CGRect rect = CGRectMake(0, 0, 100*8, 75);
48+
self.thumnailView.frame = rect;
49+
self.scrollView.contentSize = rect.size;
50+
51+
[self touchedAtIndex:0];
52+
}
53+
54+
- (void)viewDidUnload
55+
{
56+
[self setScrollView:nil];
57+
[self setThumnailView:nil];
58+
[self setImageView:nil];
59+
[super viewDidUnload];
60+
// Release any retained subviews of the main view.
61+
// e.g. self.myOutlet = nil;
62+
}
63+
64+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
65+
{
66+
// Return YES for supported orientations
67+
return (interfaceOrientation == UIInterfaceOrientationPortrait);
68+
}
69+
70+
- (void)touchedAtIndex:(NSInteger)index
71+
{
72+
self.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image%02d.jpg", index+1]];
73+
}
74+
75+
@end
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// ImageView.h
3+
// ImageViewTap
4+
//
5+
// Created by Hiroshi Hashiguchi on 11/06/21.
6+
// Copyright 2011 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class ImageViewTapViewController;
12+
@interface ThumbnailView : UIView {
13+
14+
ImageViewTapViewController* viewController_;
15+
16+
NSMutableArray* imageList_;
17+
18+
NSInteger selectedIndex_;
19+
20+
}
21+
22+
@property (nonatomic, assign) IBOutlet ImageViewTapViewController* viewController;
23+
@property (nonatomic, retain) NSMutableArray* imageList;
24+
@end
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// ImageView.m
3+
// ImageViewTap
4+
//
5+
// Created by Hiroshi Hashiguchi on 11/06/21.
6+
// Copyright 2011 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "ThumbnailView.h"
10+
#import "ImageViewTapViewController.h"
11+
12+
@implementation ThumbnailView
13+
@synthesize viewController;
14+
@synthesize imageList;
15+
16+
- (id)initWithFrame:(CGRect)frame
17+
{
18+
self = [super initWithFrame:frame];
19+
if (self) {
20+
// Initialization code
21+
}
22+
return self;
23+
}
24+
25+
- (void)drawRect:(CGRect)rect {
26+
27+
CGPoint p = CGPointZero;
28+
for (UIImage* image in self.imageList) {
29+
[image drawAtPoint:p];
30+
p.x += image.size.width;
31+
}
32+
[[UIColor greenColor] set];
33+
CGRect frame = CGRectMake(selectedIndex_*100, 0, 100, 75);
34+
UIRectFrame(frame);
35+
}
36+
37+
- (void)dealloc
38+
{
39+
[super dealloc];
40+
}
41+
42+
43+
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
44+
{
45+
UITouch* touch = [touches anyObject];
46+
CGPoint location = [touch locationInView:self];
47+
48+
selectedIndex_ = location.x / 100;
49+
[self setNeedsDisplay];
50+
[self.viewController touchedAtIndex:selectedIndex_];
51+
}
52+
@end

0 commit comments

Comments
 (0)