2009-09-07 5 views
0

내 코드에 디졸브 전환을 어떻게 추가 할 수 있습니까?코드에 디졸브 변환을 어떻게 추가 할 수 있습니까? (만화책)

나는 애플의 코드를 보았지만 아무 소용이 없었다. 어떤 아이디어?

#import "ApotheosisViewController.h" 

@implementation ApotheosisViewController 

@synthesize scrollView1; 

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { 
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

const CGFloat kScrollObjHeight = 320.0; 
const CGFloat kScrollObjWidth = 480.0; 
const NSUInteger kNumImages = 40; 


- (void)layoutScrollImages 
{ 
UIImageView *view = nil; 
NSArray *subviews = [scrollView1 subviews]; 

// reposition all image subviews in a horizontal serial fashion 
CGFloat curXLoc = 0; 
for (view in subviews) 
{ 
    if ([view isKindOfClass:[UIImageView class]] && view.tag > 0) 
    { 
    CGRect frame = view.frame; 
    frame.origin = CGPointMake(curXLoc, 0); 
    view.frame = frame; 

    curXLoc += (kScrollObjWidth); 
    } 
} 

// set the content size so it can be scrollable 
[scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), [scrollView1 bounds].size.height)]; 
} 

- (void)viewDidLoad 
{ 
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor]; 

// 1. setup the scrollview for multiple images and add it to the view controller 
// 
// note: the following can be done in Interface Builder, but we show this in code for clarity 
[scrollView1 setBackgroundColor:[UIColor blackColor]]; 
[scrollView1 setCanCancelContentTouches:NO]; 
scrollView1.indicatorStyle = UIScrollViewIndicatorStyleBlack; 
scrollView1.clipsToBounds = NO; // default is NO, we want to restrict drawing within our scrollview 
scrollView1.scrollEnabled = YES; 

// pagingEnabled property default is NO, if set the scroller will stop or snap at each photo 
// if you want free-flowing scroll, don't set this property. 
scrollView1.pagingEnabled = YES; 

// load all the images from our bundle and add them to the scroll view 
NSUInteger i; 
for (i = 1; i <= kNumImages; i++) 
{ 
    NSString *imageName = [NSString stringWithFormat:@"image%d.jpg", i]; 
    UIImage *image = [UIImage imageNamed:imageName]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 

    // setup each frame to a default height and width, it will be properly placed when we call "updateScrollList" 
    CGRect rect = imageView.frame; 
    rect.size.height = kScrollObjHeight; 
    rect.size.width = kScrollObjWidth; 
    imageView.frame = rect; 
    imageView.tag = i; // tag our images for later use when we place them in serial fashion 
    [scrollView1 addSubview:imageView]; 
    [imageView release]; 
} 
[self layoutScrollImages]; // now place the photos in serial layout within the scrollview 

} 

- (void)dealloc 
{ 
[scrollView1 release]; 

[super dealloc]; 
} 

- (void)didReceiveMemoryWarning 
{ 
// invoke super's implementation to do the Right Thing, but also release the input controller since we can do that 
// In practice this is unlikely to be used in this application, and it would be of little benefit, 
// but the principle is the important thing. 
// 
[super didReceiveMemoryWarning]; 
} 

@end 

답변

0

내가 게시 한 코드가 디졸브 전환과 관련이 있는지 즉시 알 수 없습니다. 당신이 하나 개의보기에서 다른로 이동하려는 경우

, 당신은 당신의 코드에 넣고 수 :

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 

에서 하나 개의 ViewController에 대한 :

self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 

및 한보기에서 다른보기로 전환 :

[self presentModalViewController:otherViewController animated:YES];