在其中輕鬆地創建它是通過使用的UIView的類方法如下的唯一方法:
這一代碼進入了MyViewController.h文件中:
@interface MyViewController : UIViewController
{
UIImageView* imageView1;
UIImageView* imageView2;
}
@end
此代碼那張MyViewController.m文件中:
@implementation MyViewController
- (void) dealloc
{
[imageView2 release];
[imageView1 release];
[super dealloc];
}
- (void) loadView
{
self.view = [[UIView alloc] initWithFrame : CGRectMake (0, 0, 768, 1004)];
UIImage* image1 = [[UIImage alloc] initWithContentsOfFile : @"image1.png"];
UIImage* image2 = [[UIImage alloc] initWithContentsOfFile : @"image2.png"];
imageView1 = [[UIImageView alloc] initWithImage : image1];
imageView2 = [[UIImageView alloc] initWithImage : image2];
[imageView1 setFrame : CGRectMake (0, 0, 768, 1004)];
[imageView1 setFrame : CGRectMake (0, 0, 768, 1004)];
[self.view addSubview : imageView1];
[image2 release];
[image1 release];
}
- (void) viewDidUnload
{
imageView2 = nil;
imageView1 = nil;
[super viewDidUnload];
}
- (void) touchesBegan : (NSSet*) touches withEvent : (UIEvent*) event
{
[UIView beginAnimations : nil context : nil];
[UIView setAnimationCurve : UIViewAnimationCurveLinear];
[UIView setAnimationDuration : 0.25];
if (imageView1.superview != nil)
{
[UIView setAnimationTransition : UIViewAnimationTransitionCurlUp forView : self.view cache : YES];
[imageView1 removeFromSuperview];
[self.view addSubview : imageView2];
}
else
{
[UIView setAnimationTransition : UIViewAnimationTransitionCurlDown forView : self.view cache : YES];
[imageView2 removeFromSuperview];
[self.view addSubview : imageView1];
}
[UIView commitAnimations];
}
@end
由於在本例中,第e UIViewController以編程方式創建,使用「loadView」方法創建由視圖控制器管理的視圖和該視圖將管理的子視圖。我希望這有幫助。乾杯。
鏈接上顯示「HOTLINKING PREVENTION IMAGE」。請將圖片上傳到我們可以看到的地方。 – kennytm 2010-07-07 14:09:43
[可以重新使用iBooks應用程序僅使用Core Animation重現3D翻頁效果,還是需要使用OpenGL ES?](http://stackoverflow.com/questions/3189575/could-you-recreate -e-3d-page-turning-effect-seen-the-ibooks-app-using-only-c) – 2010-07-07 16:15:18