苹果官方API翻译1.UIImageViewAUIImageViewobjectdisplaysasingleimageorasequenceofanimatedimagesinyourinterface.ImageviewsletyouefficientlydrawanyimagethatcanbespecifiedusingaUIImageobject.Forexample,youcanusethisclasstodisplaythecontentsofmanystandardimagefiles,suchasJPEGandPNGfiles.Youcanconfigureimageviewsprogrammaticallyorinyourstoryboardfileandchangetheimagestheydisplayatruntime.Foranimatedimages,youcanalsousethemethodsofthisclasstostartandstoptheanimationandspecifyotheranimationparameters.2.UIImageAUIImageobjectmanagesimagedatainyourapp.Youuseimageobjectstorepresentimagedataofallkinds,andtheUIImageclassiscapableofmanagingdataforallimageformatssupportedbytheunderlyingplatform.Imageobjectsareimmutable,soyoualwayscreatethemfromexistingimagedata,suchasanimagefileondiskorprogrammaticallycreatedimagedata.Animageobjectmaycontainasingleimageorasequenceofimagesyouintendtouseinananimation.3.NSTimerYouusetheNSTimerclasstocreatetimerobjectsor,moresimply,timers.Atimerwaitsuntilacertaintimeintervalhaselapsedandthenfires,sendingaspecifiedmessagetoatargetobject.Forexample,youcouldcreateanNSTimerobjectthatsendsamessagetoawindow,tellingittoupdateitselfafteracertaintimeinterval.Timersworkinconjunctionwithrunloops.Touseatimereffectively,youshouldbeawareofhowrunloopsoperate—seeNSRunLoopandThreadingProgrammingGuide.Noteinparticularthatrunloopsmaintainstrongreferencestotheirtimers,soyoudon’thavetomaintainyourownstrongreferencetoatimerafteryouhaveaddedittoarunloop.Atimerisnotareal-timemechanism;itfiresonlywhenoneoftherunloopmodestowhichthetimerhasbeenaddedisrunningandabletocheckifthetimer’sfiringtimehaspassed.Becauseofthevariousinputsourcesatypicalrunloopmanages,theeffectiveresolutionofthetimeintervalforatimerislimitedtoontheorderof50-100milliseconds.Ifatimer’sfiringtimeoccursduringalongcalloutorwhiletherunloopisinamodethatisnotmonitoringthetimer,thetimerdoesnotfireuntilthenexttimetherunloopchecksthetimer.Therefore,theactualtimeatwhichthetimerfirespotentiallycanbeasignificantperiodoftimeafterthescheduledfiringtime.SeealsoTimerTolerance.4.UIScrollViewUIScrollViewisthesuperclassofseveralUIKitclassesincludingUITableViewandUITextView.ThecentralnotionofaUIScrollViewobject(or,simply,ascrollview)isthatitisaviewwhoseoriginisadjustableoverthecontentview.Itclipsthecontenttoitsframe,whichgenerally(butnotnecessarily)coincideswiththatoftheapplication’smainwindow.Ascrollviewtracksthemovementsoffingersandadjuststheoriginaccordingly.Theviewthatisshowingitscontent“through”thescrollviewdrawsthatportionofitselfbasedontheneworigin,whichispinnedtoanoffsetinthecontentview.Thescrollviewitselfdoesnodrawingexceptfordisplayingverticalandhorizontalscrollindicators.Thescrollviewmustknowthesizeofthecontentviewsoitknowswhentostopscrolling;bydefault,it“bounces”backwhenscrollingexceedstheboundsofthecontent.Theobjectthatmanagesthedrawingofcontentdisplayedinascrollviewshouldtilethecontent’ssubviewssothatnoviewexceedsthesizeofthescreen.Asusersscrollinthescrollview,thisobjectshouldaddandremovesubviewsasnecessary.Becauseascrollviewhasnoscrollbars,itmustknowwhetheratouchsignalsanintenttoscrollversusanintenttotrackasubviewinthecontent.Tomakethisdetermination,ittemporarilyinterceptsatouch-downeventbystartingatimerand,beforethetimerfires,seeingifthetouchingfingermakesanymovement.Ifthetimerfireswithoutasignificantchangeinposition,thescrollviewsendstrackingeventstothetouchedsubviewofthecontentview.Iftheuserthendragstheirfingerfarenoughbeforethetimerelapses,thescrollviewcancelsanytrackinginthesubviewandperformsthescrollingitself.SubclassescanoverridethetouchesShouldBegin:withEvent:inContentView:,pagingEnabled,andtouchesShouldCancelInContentView:methods(whicharecalledbythescrollview)toaffecthowthescrollviewhandlesscrollinggestures.Ascrollviewalsohandleszoomingandpanningofcontent.Astheusermakesapinch-inorpinch-outgesture,thescrollviewadjuststheoffsetandthescaleofthecontent.Whenthegestureends,theobjectmanagingthecontentviewshouldshouldupdatesubviewsofthecontentasnecessary.(Notethatthegesturecanendandafingercouldstillbedown.)Whilethegestureisinprogress,thescrollviewdoesnotsendanytrackingcallstothesubview.TheUIScrollViewclasscanhaveadelegatethatmustadopttheUIScrollViewDelegateprotocol.Forzoomingandpanningtowork,thedelegatemustimplementbothviewForZoomingInScrollView:andscrollViewDidEndZooming:withView:atScale:;inaddition,themaximum(maximumZoomScale)andminimum(minimumZoomScale)zoomscalemustbedifferent.5.UIPageControlThisapplicationprimarilydemonstratesuseofUIScrollView'spagingfunctionalitytousehorizontalscrollingasamechanismfornavigatingbetweendifferentpagesofcontent.WiththeiPad,thistypeofuserinterfaceisnotreallynecessarysincethescreenislargerallowingformorecontentanddetailedinformation.DesignedasauniversalapplicationforbothiPhoneandiPad,thissampleshowshowtousetwodifferentsetsofcontent,dependingonwhichdevicethesampleisrunning.TheideaisthattheiPhoneusesasmallersetofimages,whiletheiPadusesalargersetofimagesplusmoredetailedinformation.Asauniversalappthissampleshowshowtofactoroutthesetwo