1. IBOutlet 을 사용하지 않고 태그값을 이용해서 불러오는 방법
//
// SampleDay8ViewController.m
// SampleDay8
//
// Created by bit on 11. 5. 25..
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "SampleDay8ViewController.h"
@implementation SampleDay8ViewController
@synthesize mSwitch;
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *imageView = (UIImageView*)[self.view viewWithTag:100];
[imageView setImage:[UIImage imageNamed:@"play01.png"]];
NSMutableArray *images = [NSMutableArray arrayWithCapacity:10];
for (int i=0; i<3; i++) {
[images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"play%02d.png", i+1]]];
}
imageView.animationImages = images;
imageView.animationDuration = 0.75f;
imageView.animationRepeatCount = 0;
//[images release];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
-(IBAction)onValueChanged:(id)sender
{
1. IBOutlet 을 사용하지 않고 태그값을 이용해서 불러오는 방법
UIImageView *imageView = (UIImageView*)[self.view viewWithTag:100];
if ( mSwitch.on == YES) {
[imageView startAnimating];
}
else {
[imageView stopAnimating];
}
}
@end
댓글 없음:
댓글 쓰기
참고: 블로그의 회원만 댓글을 작성할 수 있습니다.