`
willstrong99
  • 浏览: 5415 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

最近开发iphone的一些体会

阅读更多
1,实现特效的两种用法: For example, the ViewTransitions sample project from apple uses code like: (1) CATransition *applicationLoadViewIn = [CATransition animation]; [applicationLoadViewIn setDuration:1]; [applicationLoadViewIn setType:kCATransitionReveal]; [applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; [[myview layer] addAnimation:applicationLoadViewIn forKey:kCATransitionReveal]; but there are also code snippets floating around the net that look like this: (2) [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.75]; [UIView setAnimationDelegate:self]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:myview cache:YES]; [myview removeFromSuperview]; [UIView commitAnimations]; The difference seems to be the amount of control you need over the animation. The CATransition approach gives you more control and therefore more things to set up, eg. the timing function. Being an object, you can store it for later, refactor to point all your animations at it to reduce duplicated code, etc. The UIView class methods are convenience methods for common animations, but are more limited than CATransition. For example, there are only four possible transition types (flip left, flip right, curl up, curl down). If you wanted to do a fade in, you'd have to either dig down to CATransition's fade transition, or set up an explicit animation of your UIView's alpha. Note that CATransition on Mac OS X will let you specify an arbitrary CoreImage filter to use as a transition, but as it stands now you can't do this on the iPhone, which lacks CoreImage. I have been using the latter for a lot of nice lightweight animations. You can use it crossfade two views, or fade one in in front of another, or fade it out. You can shoot a view over another like a banner, you can make a view stretch or shrink... I'm getting a lot of mileage out of beginAnimation/commitAnimations. Don't think that all you can do is: [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:myview cache:YES]; Here is a sample: [UIView beginAnimations:nil context:NULL]; { [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:1.0]; [UIView setAnimationDelegate:self]; if (movingViewIn) { // after the animation is over, call afterAnimationProceedWithGame // to start the game [UIView setAnimationDidStopSelector:@selector(afterAnimationProceedWithGame)]; // [UIView setAnimationRepeatCount:5.0]; // don't forget you can repeat an animation // [UIView setAnimationDelay:0.50]; // [UIView setAnimationRepeatAutoreverses:YES]; gameView.alpha = 1.0; topGameView.alpha = 1.0; viewrect1.origin.y = selfrect.size.height - (viewrect1.size.height); viewrect2.origin.y = -20; topGameView.alpha = 1.0; } else { // call putBackStatusBar after animation to restore the state after this animation [UIView setAnimationDidStopSelector:@selector(putBackStatusBar)]; gameView.alpha = 0.0; topGameView.alpha = 0.0; } [gameView setFrame:viewrect1]; [topGameView setFrame:viewrect2]; } [UIView commitAnimations]; As you can see, you can play with alpha, frames, and even sizes of a view. Play around. You may be surprised with its capabilities 2。捕捉touch事件: 下面是打印的一些有用信息 ---下面是UICView的声明--- You must customize UIView, and handle event. //UICView.h @interface UICView : UIView @end ---下面是UICView的定义--- //UICView.m @implementation UICView //Handle touches began event - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { printf("members count=%i\r\n", touches.count); for (UITouch *touch in touches) { printf("tap count = %i\r\n", touch.tapCount); //for dragging event, touch.tapCount is 0 } [self touchesBegin:touches withEvent:event]; //You must invoke this interface, otherwise, application may can't handle event correctly. } @end 下面是相关事件: iphone开发-UIView(touch事件) iphone 2009-03-14 08:35:04 阅读130 评论0 字号:大中小 怎样捕获手指的触摸事件呢? 理论不说了,在开发文档里面说的很详细。就说说实现。 其实就是要重写实现三个函数,如下: touch开始时会调用touchesBegan - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; UITouch *touch = [touches anyObject]; NSLog(@"touch view++++++%@", [touch view]); // [touch view]获得当前touch的view //[allTouches count]获得当前touch的是否是多触摸,如果 [allTouches count] == 1就不是多触摸。 switch ([allTouches count]) { case 1: { // potential pan gesture UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; [self setPanningModeWithLocation:[touch locationInView:self]]; } break; case 2: { // potential zoom gesture UITouch *touch0 = [[allTouches allObjects] objectAtIndex:0]; UITouch *touch1 = [[allTouches allObjects] objectAtIndex:1]; CGFloat spacing = [self eucledianDistanceFromPoint:[touch0 locationInView:self] toPoint:[touch1 locationInView:self]]; [self setZoomingModeWithSpacing:spacing]; } break; default: [self resetTouches]; break; } } //是指触摸移动时,调touchesMoved #define ZOOM_IN_TOUCH_SPACING_RATIO (0.75) #define ZOOM_OUT_TOUCH_SPACING_RATIO (1.5) - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { //获取当前touch的点 CGPoint location = [touch locationInView:self]; switch ([allTouches count]) { case 1: { } break; case 2: { UITouch *touch0 = [[allTouches allObjects] objectAtIndex:0]; UITouch *touch1 = [[allTouches allObjects] objectAtIndex:1]; CGFloat spacing = [self eucledianDistanceFromPoint:[touch0 locationInView:self] toPoint:[touch1 locationInView:self]]; CGFloat spacingRatio = spacing / lastTouchSpacing_; if (spacingRatio >= ZOOM_OUT_TOUCH_SPACING_RATIO){ [self zoomIn]; } else if (spacingRatio
0
1
分享到:
评论
1 楼 lukejin 2010-03-22  
这写的对读者也太不友好了吧,哈哈,。

相关推荐

    iPhone开发基础教程电子书

    这本书也写得非常好,里面非常系统地讲解了开发iphone和ipad上面的游戏需要注意的一些问题,比如内存很少的问题等。同时书里还涉及了cocos2d开发中大部分的内容,基本上可以说是所有的内容。同时,这本书的作者的...

    如何学好Iphone开发

    文章的最后部分,作者以个人学习经历和心得体会,鼓励后来者不要害怕开始,而是要通过不断实践和学习,达到精通iPhone开发的目标。同时,为初学者和已经有一定基础的开发者分别提供了学习指导和交流的平台,展示了...

    iphone 基础开发教程源码

    iphone教程源码,是不错的教程资料,结合源码可以更好的体会到精髓。同时也能节约不少时间

    C#游戏开发快速入门

    使用它开发的游戏可以运行在所有的主流游戏平台上,如,Windows、Xbox、Mac、iPhone、Windows Phone 8、Android等等。 要开发游戏,C#需要学的有多精通才行?对Unity得多熟悉才行?得用多长时间才能做出一个能拿得...

    android开发资料大全

    快到毕业的季节了,积累了一些andorid面试题,希望能帮助同学 android面试全跟踪,最真实的android面试经历 揭开应用推广运营背后的秘密 APP应用开发盈利的九种商业模式详细介绍(图) 专题连载一:品牌厂商为什么...

    ios开发介绍及心得.docx

    本文档将详细介绍iOS开发的核心概念,并分享一些个人的心得体会。 #### iOS开发的核心概念 ##### 1. **MVC架构模式** - **定义与作用**:MVC(Model-View-Controller)架构模式是iOS开发中最常用的设计模式之一。...

    PumpkinFace

    《PumpkinFace:苹果iOS应用开发初探》 在当今移动互联网的浪潮中,iPhone应用程序的开发无疑占据了重要的地位。...在探索" PumpkinFace"的过程中,我们会深刻体会到iOS开发的魅力,同时也能提高解决实际问题的能力。

    2012年春训学习心得体会.doc

    文档标题和描述并未直接涉及IT行业的具体知识点,但可以从内容中提炼出一些普遍适用的学习方法和理论应用,这些原则在IT行业中同样具有指导价值。 首先,文档强调了思想准备和学习的重要性,这在IT领域中也同样适用...

    LearnCOnTheMac

    在Mac上学习C语言是很多编程初学者和Mac用户的重要课题。为了在Mac上熟练掌握C语言,我们首先需要了解...通过这本书,读者可以系统地学习C语言的基础知识和高级应用,同时了解如何利用C语言来开发Mac和iPhone上的应用。

    Unity笔记 - 【狗刨学习网】.pdf

    Unity 提供了一个集成的开发环境,支持Windows和Mac OS X操作系统,并能够发布游戏至多种平台,包括Windows、Mac、Wii、iPhone、Windows phone 8、Android,以及通过Unity Web Player插件发布网页游戏。 Unity3D的...

    QELearningDemoProject:此存储库提供了3个练习题的解决方案,可在Amazon上搜索appium书,在Amazon上搜索iphone 11 pro,最后在Wayfair上选择组合式家具

    在这个任务中,智能体会模拟用户浏览家具,筛选出符合特定条件(例如风格、价格、尺寸)的组合式家具,然后可能还需要完成购买流程。 项目使用Java作为编程语言,Java以其稳定性和跨平台性广泛应用于大型企业级应用...

    IOS学习笔记

    OS开发学习笔记,包含基本原理讲解及每篇附上的示例程序代码!帮助iOS开发初学者一步一步进阶,分享最新的学习心得和体会! http://blog.csdn.net/column/details/ryan-zone.html

    人工智能与信息社会考试答案 (2).docx

    较大的α值意味着智能体将更多地依赖于最近的经验,这有助于快速适应环境的变化;相反,较小的α值意味着智能体会更多地依赖于过去积累的知识,这有助于保持稳定性。在实践中,找到合适的α值对于确保学习过程既能够...

    Redrock-Final-exam

    模拟器请选择:iPhone SE2 雷德洛克最终考试 1.APP简介 仿写知乎日报 2.APP构成板块,开发思路 1.主界面:横幅+酒吧+新闻列表 2.新闻详情Webkit 3.登录界面,设置界面,收藏和消息 3.重要技术 AFN,...

    幸福幸福不一样.doc

    无论是在软件开发、产品设计还是服务提供上,都应将这一理念融入其中,以创造更加个性化、人性化的科技环境,使技术成为提升人们幸福感的有力工具。通过教育和实践,我们可以培养新一代的IT专业人士,他们不仅懂得...

Global site tag (gtag.js) - Google Analytics