아이폰 어플에 동적으로 이미지,동영상 만드는 방법 정리

#import "ImagesViewController.h"

#import "Constants.h"

#define kMinDuration 0.0

#define kMaxDuration 10.0

@implementation ImagesViewController

@synthesize imageView, slider;

- (void)dealloc

{

[imageViewrelease];

[sliderrelease];

[superdealloc];

}

- (void)viewDidLoad

{

[superviewDidLoad];

self.title = NSLocalizedString(@"ImagesTitle", @"");

// set up our UIImage with a group or array of images to animate (or in our case a slideshow)

UIImage *im5 = [[UIImagealloc] initWithContentsOfFile:[[NSBundlemainBundle] pathForResource:@"scene1"ofType:@"jpg"]]; 

UIImage *im1=[[UIImagealloc] initWithContentsOfFile:[[NSBundlemainBundle] pathForResource:@"scene2"ofType:@"jpg"]];

UIImage *im2=[[UIImagealloc] initWithContentsOfFile:[[NSBundlemainBundle] pathForResource:@"scene3"ofType:@"jpg"]];

UIImage *im3=[[UIImagealloc] initWithContentsOfFile:[[NSBundlemainBundle] pathForResource:@"scene4"ofType:@"jpg"]];

UIImage *im4=[[UIImagealloc] initWithContentsOfFile:[[NSBundlemainBundle] pathForResource:@"scene5"ofType:@"jpg"]];

NSMutableArray *ma=[[NSMutableArrayalloc]init];

[ma addObject:im1];

[ma addObject:im2];

[ma addObject:im3];

[ma addObject:im4];

[ma addObject:im5];

NSArray *arry=ma;

self.imageView.animationImages =arry;

//정적으로 동영상 만드는 방식

//self.imageView.animationImages = [NSArray arrayWithObjects:

//[UIImage imageNamed:@"scene1.jpg"],

//[UIImage imageNamed:@"scene2.jpg"],

//[UIImage imageNamed:@"scene3.jpg"],

//[UIImage imageNamed:@"scene4.jpg"],

//[UIImage imageNamed:@"scene5.jpg"],

//  nil];

imageView.animationDuration = 5.0;

[self.imageViewstopAnimating];

// Set the appropriate accessibility labels.

[self.imageViewsetIsAccessibilityElement:YES];

[self.imageViewsetAccessibilityLabel:self.title];

[self.slidersetAccessibilityLabel:NSLocalizedString(@"DurationSlider",@"")];

}

// called after the view controller's view is released and set to nil.

// For example, a memory warning which causes the view to be purged. Not invoked as a result of -dealloc.

// So release any properties that are loaded in viewDidLoad or can be recreated lazily.

//

- (void)viewDidUnload

{

[superviewDidUnload];

self.imageView = nil;

self.slider = nil;

}

// slown down or speed up the slide show as the slider is moved

- (IBAction)sliderAction:(id)sender

{

UISlider* durationSlider = sender;

self.imageView.animationDuration = [durationSlider value];

if (!self.imageView.isAnimating)

[self.imageViewstartAnimating];

}

#pragma mark -

#pragma mark UIViewController delegate methods

// called after this controller's view was dismissed, covered or otherwise hidden

- (void)viewWillDisappear:(BOOL)animated

{

[self.imageViewstopAnimating];

// restore the nav bar and status bar color to default

self.navigationController.navigationBar.barStyle = UIBarStyleDefault;

[UIApplicationsharedApplication].statusBarStyle = UIStatusBarStyleDefault;

}

// called after this controller's view will appear

- (void)viewWillAppear:(BOOL)animated

{

[self.imageViewstartAnimating];

// for aesthetic reasons (the background is black), make the nav bar black for this particular page

self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

// match the status bar with the nav bar

[UIApplicationsharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;

}

@end



출처 : http://blog.naver.com/PostList.nhn?blogId=philipousys¤tPage=14
Posted by 오늘마감

티스토리 툴바