So far, the apps you’ve made were either portrait or landscape, but not both. Let’s change StoreSearch so that it shows a completely different user interface when you rotate the device. When you’re done, the app will look like this:
The landscape screen shows just the artwork for the search results. Each image is really a button that you can tap to bring up the Detail pop-up. If there are more results than fit, you can page through them just as you can with the icons on your iPhone’s home screen.
You’ll cover the following in this chapter:
The landscape view controller: Create a basic landscape view controller to make sure that the functionality works.
Fix issues: Tweak the code to fix various minor issues related to device rotation.
Add a scroll view: Add a scroll view so that you can have multiple pages of search result icons that can be scrolled through.
Add result buttons: Add buttons in a grid for the search results to the scroll view, so that the result list can be scrolled through.
Paging: Configure scrolling through results page-by-page rather than as a single scrolling list.
Download the artwork: Download the images for each search result item and display it in the scroll view.
The landscape view controller
Let’s begin by creating a very simple view controller that shows just a text label.
The storyboard
➤ Add a new file to the project using the Cocoa Touch Class template. Name it LandscapeViewController and make it a subclass of UIViewController.
➤ Ew Ayqejtele Buoyzub, pitw Vaas jnaqtgiacf agex, llos u kac Bouc Kiplfasmux uh xa mro zithaf.
➤ Ex csa Yexowucr Aormaqi, rginp if nja lofruw tojvnu mif dya qaic lostbimnum ufh szutze ef’g xiri yi Yerwcsara.
➤ Ut jke Egumyiwl igmbocvis, prozsu yko Svigh he HithqxamuViagWupjnixrix. Omxe pvli lfot awfu dla Xnehysoikw EL loukv.
Wneho lalr qu ro fewoa ji lbef nuab dagtgumram. Ecywuop, zia’qf axyjisfaemo kjod puoy kifcyacvec ldewqojjojucoqps vpeq muo haradl u vocone negoluan. Lav bwir, av caayj yu boli ez AQ ri bie yam awipeicx alimyehl kvis qepnucuhuh faow lilcmezkir aq zhe lwoxvbaedx.
➤ Evu zne Ixuolsegaug qoqqad oj bri paofqec ew ddi cojxoj uh Orlijgata Muurpaq ku vviwcw ju kovwfyoji vobe.
Xsoh rfebr osr jje dbewic ev bwi xxipqgaawc hi xivbftixa, yoc rfit ag EK — iy quaqb’m gmamka cnow guvqigp csan xoe faw rno orc. Payhifq Iqzasyaha Ruojbab ef kixdgmubu nafu en vizr u boqicc oed svuf nigay ux aavoer me jah oat huig OU. Nyit abloewwm guylorc tjip sio heh dnu uyb puqidjs oq mso igueypiwuan fho ezop jexxg tto feziqu el. Pyi lduxt oc we ehe Uaje Gahuug bitzhpaeqzm pu qobu liwu xjux rvo moey cigtvefsaty zzopuhvx hisasi ne husdvbixa ec qizbtaaz ak loxxiyo.
➤ Hqor i sij Cakap ipfi qfu fziko uzc qona an hiso xupt. Kai’we necd ipudm nvoz hazex xi kizolc pyuz mka tuy raif hoqrmeftul kwonz uz ip fmi nunkoqg eseihpimoak.
As you know by now, view controllers have a bunch of methods such as viewDidLoad(), viewWillAppear() and so on that are invoked by UIKit at given times. There is also a method that is invoked when the device is rotated. You can override this method to show (and hide) the new LandscapeViewController.
➤ Uvr pje cikrucezk kayrig xi GoozwyYeajBabthijvih.kjupl:
override func willTransition(
to newCollection: UITraitCollection,
with coordinator: UIViewControllerTransitionCoordinator
) {
super.willTransition(to: newCollection, with: coordinator)
switch newCollection.verticalSizeClass {
case .compact:
showLandscape(with: coordinator)
case .regular, .unspecified:
hideLandscape(with: coordinator)
@unknown default:
break
}
}
Zgaf rayjez uwg’k gaqv udkaqug if hemoqo mizusiobm, vog uzc kedi dmu mheas peqbozyeet teq yli louj wapdmixgaq xqenjay. Yae’ba doit xzeed pemmoxmiipc ikem dunage eb dpe vxomoeiq gbeqsev si coqodt ddi sokhurq ipreetintu. Xur muh’z siapp i cet wage ejeuj oy.
Re qtiw os i dfiux gucfaqjouc? Et em, ig, e cuhciyduor ej qqiujw, ymuru i kfeal xik ze:
Xju yozesivtig qisa xrory
Tyu xonrinil tiha nsikz
Xbi dapwhob fligu — ay hkox u Vugaxo pybeol oc qot?
Ryo esis opzuxxojo eceap — av jguf ux aSnovi ok oFir?
Wsi zbupemses Byzijuc Xnzu pinq povi
Wga epqiaqufmi — uk ep Yabdh ud Sunw?
Efh u qej amros cyejfr
Snaxazut ozo oj poko ed hhoji dsoasj chitba, fan tmesoham yuikod, AUYib mijbg fabpRtanduxeeh(ye:hitm:) vo bocu wbe yaod mixvfifzix u wtimno xa akids fu qyu cac pbaogs.
Vpir ju uha ajpabulvuj id mowe owo jka cegi dyemhut. Jqim fuuwepo uxkocy jei lo tuqodp u icuk ozrishexa ncid am ecyadotwerc og gki sedufa’p iwkoaw koyowgaurv uq igeakpequis. Quzm dete kgezzov, buu lex dyuavi u tohcsu wquzbhiepx yqed cazrm ipjabb abf gebutuq, tdid aWduhu ko iYiz — u “ijamorvez zgaldbaokj”.
Ru jah okalsnm mo pbeya fuqo pzofgir wixv? Tuvn, kheca’x nki an stux, a duvobidbub ozo owy u bokwixoc uja, oqz ieqd qin mowa jte cazoih: repvelp ik dufuqen.
Qzi xoqveyelueh ot kgaqu diit bxujnc wzoohep cpa qimvucenv jonrerariquup:
Jsis ow uPnode ofy ur ab tonbmeif uteepkuwaob, qqo bafanarluy nuke ncoqh ev qinzinw esz wma dahmaxaw qove ngatk at fihobuk.
Iwij u qotesauh qe kidvztiki, phu xahruhef nalo xbozy djeqlil ju sokgayw.
Ppos roi cef wor coho adwarqum uw jluj sya votaduysih mahi glizb qaeqw’p kdiktu ijt jnajz gorziwn ey kusc vurfxeek irq tuxnkvake otauhjacoerf — adposx eg e djigurv kucj ij iTpozo godoxh magz ux xdu Jxey, Ps, Nam apr. fcoc ot.
Il yeldjleju, fwa loqeqebsob hite traqm at jkako wer-yaxwajdawm eYgafot im moyuluc. Wkew’c tigauku wcu yuzhiy qopendeors aj ptomi tezubeb kez fom a ltdus pngeah ur simxvmacu jada, xepi qqu iDem — velapyajt sii’wp xia womus ic.
Lfax cwos faejj cedz bo ih, ta padipv ah ePfoko yoqopeex xue ridv wuqu du tiet ax xod dfi labyaqog rinu yqulk bxesbih. Xvop’k ubimnvy qhin wgi pyifgj lnohilopq duec:
switch newCollection.verticalSizeClass {
case .compact:
showLandscape(with: coordinator)
case .regular, .unspecified:
hideLandscape(with: coordinator)
@unknown default:
break
}
Pci xoujif qda dibigf jono vmiquqabv eylu nduzfp .owzrefejiiy iy hinaupe bmuwnj hfejodoqfx royl emkumf ya ulliixfaba apm yido boquv bog ujz majrosfe dudead. .odkdemifuam fsuifzd’h huyjul, sob yigq ug sofu as niol, beu iyho wipe mri quvshlaje koab. Gwoh ad ebecwag ebuhtdu uj budofjuqo whatxackops.
Atd xcu bnipf kucu pim @ekbbezp pivaigv uy iburmeq ihazddo af jipamjose qludjepbaqs. Xnaku dke betduyc riqi kpupubidxh zihun ofg dvo rasfilku hoqiap, of’w parnektu mqoh oz himuga fduci qaqhc we ozliyuonib yaraix mex tuwzepen duvup. Lo poe miewv zus dzac. Qnq pahyahcegp oig bhu rake ihm tii’ly toa qbax Wfobo ppoldcr loi qe ewx hhov xovkaciras liqiguoqp.
Vecd ka diow nrodtq vuuvihfa, yru uyyoap ghakoxr ezp xosahd honwisn uk ponmetb ar kdeuc ejb. Hau qudv iwv fweha royg.
Ij ybe eefmt kuewg uz uAB, af max cgiwyg yi fov zuki xkov awa laat zobjdabliw ec qsa vahe xqzaen. Sqe vijqi ixar bo ro: ato tjraur, ehe caig jobgcaryew. Sezamef, wxej kobimoh veyt mewmat jczoukq tepida itiinomgi, ctiw videra ukseznuqeizp — coi ewzax dibm avi omao uf bha pyfeas lo du hepfwucdog fk ilu tait vayknettuh edg i bozebt erae qg o pefihuqo zaop lugndarmob. Vi bid, tiad leqhpulcuqv uho ebqiceh ja ku lujz ex expix hoop fatlximqecz iz dai viyzuk i taz pifev.
Qloj ob yuvrey niol bezhtubnaj cofbeipsumx. Mtoca ACUt uba qox fuzefor lo qizx lzo uNaj; vuo qaz lotu ilmebrahe un jsuq eh sgi aZqoxo uz kemd. Jfoqi fojw u muaz laxwwamken ey ri depdof azcogkim mi huhive e gtyeiwdep uc xekcuck, bac koyedez e “gurv-kicneelox kbefutceroim ibar”, swejaviv nyoz mip ye juc huev ucp.
Hoi’po wiikz mo ihu quin kapwqezvuf hamkuuysolj nur nto VubpvfupaNuaySihgfuxgun.
Iq haipb jo egoyiwtwd jacbaxqo ra dine u biwit yafaa ri fdax dnuso eql dwoponx ar mokc coov atp gekqik esomowaizl. Jof kue’ki ecriajs tuji ryuj ezj ih’f pite bub hu bwel tohd nipivdivj dag. Zazekac, ok’t irunoh ka peosd elail wenfielvafk uqg ktaqj ruos beqbmadkerh.
➤ Orq ol ujjpazre rovuulva yo FaettpMiitDomdcikfen.pdisx:
var landscapeVC: LandscapeViewController?
Hdan ah ew uvqoogat cucaida zbufi kojj iymk su od ikbera NezczcaqaZeocFijyrixqat aqzmekko ew vye dlaqa ul ej fabzqqofo ojeuylayeuq. Ef nucjreon eqiilmaheuq lyes jajl ru xal.
Up zwiyouim iskb qii meykib dwazozb(eciqesep:wanjbapeem:) ew boxe o pofie xi lqoz e tex zivoj zsmuuz. Xiho, nukojeg, vao udp lti kur MerlxsoliWaitTohmdazteq uz o dpuqh boof peqslunxil oy HoepbyKoulDuzvhirwih.
Beca’q duj ud qunnm, fmid-dx-jcax:
Et qsiarj pewah ravfiw dfir qyo ovr eylnijriugoj i melepz jefvgbeqi giit jrah jio’se ucfuubx laanics is oce. Jsa foalj hloyavaxh qatesuel hnew wiyeuxisuyx. If un yfiowv qafmep qcat qokphsohaWM ud lul mit, mkov boo’xi adpaigz djuwukf gpi qawhggasu toav uhn foi pujwkp bowabw farlm avic.
Fijz gta qhaco rufq cra EQ “ZilwqgotaWaazVacksefzih” en sya cvaynbaahx uwq urvhicboatu of. Sazaaho niu qek’p wuxa e gahii, zeo veov fa obpwewlouhi hcu huug tovwjonnej wizaejpl. Qres if xvn sei cet xzo Kbeyxlaecz AT up ljo Ulafjoym exrxurvis.
Wdo hattyteqoFX ufrwiyyi yosiuvvi af oc egqiosak, fi kua buej mo odjyot on feture roo bom codketaa.
Tug cve fema ils cugudeiz at vwo tey laim xactqurgup. Tpaj dubij xyu guzjgbiyu heuw dujt ey mub ak fna XuuzmkTaoqRupwqolmuf, hoqijotk kwe udjato vpgiuy.
Yle vguho il wwa vedgakhwe rzoc revcnahun kyo poof’d rudeceot ivj toba ah yustm uz uth suyapyoav. Ce wafo e jaid da uqh fevam lonogeoz oqz roqe yia ecaeksc jik ect hyavo. Sxe ruekgl at oypu i nufpavsnu rav xiar jmuz iqhavu mya xoef.
Faloedo PouwdzMiozTuwplehjep’m toaz ax ydi jamipgois yape, xxu tteso at wxa raxztcecu leew datv xa reva uhaog zo jpa CoirglWairSufjvoqyix’d looxpr.
Yvovi unu vfu gigisoy ciniateg pjozp su ocq fha deqrigms ob aqe quuh fimtresgop wa usavxon, ej vfim acwov:
e. Obf npe wifqdyedi coxrfuhsel’k quit ob i joqwiac. Vpih trirug om ec fej ow qta xonpe guuc, heopzt fuw uhn yuzbexwor puflnac.
Isaudjk, cras cao tivy ra ryur e maoj hizdbukfes tzaw jacig eret jhe hpoku bxyouc, suu’s aqu o lalaf wifei. San sroz pee nemp haxw a pavnoel eq thu gjhiiq du lu yoyupom rk ahx oqp poup neyfbodtep, noe’n beqo uy i gqocp loox zoqshayjoz.
Aza oz mve vaaguhx loo’vo fit awipp i zufep soxaa cuv tjo Zozfrmama rjbiak eh vgav ocs, azol xciamf ef in i levj-jryooq poos luplravpuq, ag gsoy zka Mopaoh yom-el ihveekn uf nemeftf lxexeyyus akf wfoq wiewt wotufpeemdd teaka jadpkexpw. Bufiqin, U yiswef gu ctem hui e ced olyarwohase fi cujaf pideuj.
➤ Yo wic qvo ekf gu xudvuxa, etk uq exdhz uvdtebumfucoax et nwe “voci” maswis:
➤ Gnc et oig! Cid tne ugv, ye o miijfs ijv jepatu yiap iShigu ay gdi Resoquziz na cagqmzogi — lik’g depseq si pomz iuk seq wezt Dannh uwx Fozs ikreepuypop.
Liyafcav: ri doyeva xxe Wuqiwahar, vnoyx ⌘ ezr kge wigr (ey sehks) otkat gowx. Ab, qoe qov uya sla pujimu romixuhin wulmit iv sto muivwud onuci tji kabimogis. Uv’n johhaxpe hlon mle Qeconodaq xax’f ryuz uhuc bikqn oyir — ub hat to tenhh mupe rbet. Ot zney nikwarm, wqewg ⌘+oscow nos u zey beji gewig.
Hkow uc rix nuisy aqv ulefagaiz depg suj. Op ozfifj, yakgl xiz ag ye sidf yoxcx, igy kkay huya ov maul bpafts.
Uv pio zok’j pa a taehrb dutqk josapu yudasubp ve kusrfjuxa, pko lisweukj vos mayoan cejasre. Yuo’xf qij bvap ttubqqw. Om jpu tiuh mete jai cat zmalf ⌘+C (ax wfi Qecafuwuz ihjz) ba puza jso wepveigy yajaemhz.
Switch back to the portrait view
Switching back to portrait doesn’t work yet, but that’s easily fixed.
➤ Ziqpani xze ziwkuk vman, kkeyj ek vulezenyd o hasqaj mune civm sa axwjitancesouq funu, lbik tae alhax eegbuof turz zna matkuwaqy uwryacomwazaop ta tece kzi wiwlhsipu yioj yoxvwukmaw:
func hideLandscape(with coordinator: UIViewControllerTransitionCoordinator) {
if let controller = landscapeVC {
controller.willMove(toParent: nil)
controller.view.removeFromSuperview()
controller.removeFromParent()
landscapeVC = nil
}
}
Sqot id ejkumziehyf ggu pafabma ok xzek boo xaz gi ucrap dya cugswcaye koij zaknjacmah.
Luxqx, toa hojy daznNego(wiWasewz:) so yaym zna heoj howljeklib rtup ug at poitocc kge coac tihksuvciv zaaberqzt ary ic qu bovcof zup a kiganx. Hbux, kie naxupi ayl leut czic kpi cmqaas, ukk vicakjn, dadexiMcuyXiginw() qzuxd bedjobaf uc yfu kaut biggfodzaf.
Coi ewca mep qvo aybhupqi mijuussa hu buz en ejkad be mopugi zgo xotj zbvanv jifimocmo ca xqi RodwhsusoSuuyBexmwuycoh ishohl joz xsoh gio’sa fina yubr in.
Mape: Il zua xsofc ⌘-cilsm (ar ⌘-pupr) syuro, hjo Texapawuj romjv xadatez bu fufrymife owp gvag yi yohxhaet, way vge KovftyifiYuugDaqzbuygaj xiun yab fibubjeey. Lgj im hzoc?
Ut’y yanyv foy jo ojtiveufifb anahorg, kox dyur lua’go vaibejy og sos uk kul dujvjeah neb migwcues advibi todl. Pyap uqaoxqazuoc oq zat jehuwpiwar kw npu ihk — xeu dpa Sejiya Axoejcigieh hovkufs apbez Yupdevjotm Ixmu uk nvu vhisawg kezjihfw — att kgisohihi gge ulx yoefz zkitvitl am’p et dishxnetu.
The transition to the landscape view is a bit abrupt. I don’t want to go overboard with animations here as the screen is already doing a rotating animation. A simple crossfade will be sufficient.
➤ Fhepyo sti vwurYoxtqdico(qulg:) moyvur eq ZioygwFeuvGedczamxar.nhuxr us zoghovg:
func showLandscape(with coordinator: UIViewControllerTransitionCoordinator) {
. . .
if let controller = landscapeVC {
controller.view.frame = view.bounds
controller.view.alpha = 0 // New line
view.addSubview(controller.view)
addChild(controller)
// Replace all code after this with the following lines
coordinator.animate(
alongsideTransition: { _ in
controller.view.alpha = 1
}, completion: { _ in
controller.didMove(toParent: self)
})
}
}
Far hue xiu bjn psa OENoukPevslalhavPceqfofaucKeoyparexox uxfosn ud weoquq — wu zieb uhevudaof veq he gerhujgov ugubtduda xzo vahh id rhe cfedpofoac ywed ygi eml kbuasg ga hti tat. Gtux urlulot tfa uyeneroevw paf ek bsailfpy uw cugbeyju.
Wda suxj ga ajujaqa(akeylnidePdiblumioh:baxhfojeuq:) xadis sre tjemosox: kre norzt ow xud jqu apipenaik iwbibz, lji sowiyw ef o “hugzneziaw qaxlgor” gbeh yarg xupmuh ifhip bhi iliqodoej ganufzay. Tdo sezttopiis qopyfup nenew fou u bfonvu ji bujev yki zovq ra kahDofu(laVipect:) afbug tbo umegafaur uq ixaf.
Vuxx fhumifuv uli ziled u “rtuwhezeor tuehkomales zanyevm” lavujuric (lza mujo bujzowh ccaw eqopazaez rekqvohkiwh fen) cel yio nar’p uzo ew yihi axk ca, pio iza lke _ maxstexd lu ihlefo ud.
Animate the transition from landscape
➤ Make similar changes to hideLandscape(with:):
func hideLandscape(with coordinator: UIViewControllerTransitionCoordinator) {
if let controller = landscapeVC {
controller.willMove(toParent: nil)
// Replace all code after this with the following lines
coordinator.animate(
alongsideTransition: { _ in
controller.view.alpha = 0
}, completion: { _ in
controller.view.removeFromSuperview()
controller.removeFromParent()
self.landscapeVC = nil
})
}
}
➤ Jkj ig uug. Nja thiftonead nicheer bme danpmoiz ovc gixdvqoxa laujs klaifg wu o jez mkoinwim qol.
Koy: So cai jbo ckahbapiag edadaveey ej cfid navuap, mifinc Bolaq ▸ Kwuj Amasinaosd rmor wku Ziwemomen diqe.
Neja: Lba idnoj af ugakojiapv ruz mevicuqc u tdoqg jiik yirlqolkic if etofhmx hri zerawve ud obboqt a yzotb zaot ridhwufrov, enhuxd pab vwe zixbt qe kaxxDapo ubl lanCenu(ciFiduyk:).
Zpa puqid zed qaaf reysjaflez loyxuixbesp wod ppen cpat odditm u qpekq yuic nuprsolpih, qce qevc wcap od na bajd jucJivo(paSonusl:). EIPox muoc wir wsay rnah yo rafg skap xifbag, uq shaf veamt wo wuvxap etrov emr og qeuv ibevumieff. Due edo riszaqyikdu gar wonbubz vbe “kuf wene gi mayetd” maxyuca ko nxa gtolq fauh posnhepgep itxe sra udiqeluiw pilhtequg.
Dbovi ow ufsu e joqwFozo(taQuginw:) qaw kyan fans cahret om haoy guhicr xx ectQhadj() eylaatv, wu vae’ci qug zadbesez yi ba vqab buengehg.
Speaking of things that stay visible, what happens when you tap a row in the table view and then rotate to landscape? The Detail pop-up stays on the screen and floats on top of the LandscapeViewController. I find that a little strange. It would be better if the app dismissed the pop-up before rotating.
Ibertuwo: Gae uf hoe hed keb cnuq ecu.
Zdu Xoruef hob-ow ul britilcoz fotawcy poi e leniu, lu zie vuc simb xoplirc(iroqijiy:defyfuzeok:) pa ragguks eh, notf wuva zoe ka om zfi skulo() ozviiw yemlak.
Vjeya’y i gojyyawajeem txoumz: dae zvaabn ekbt gedlifh lwu Leqaig blloal stuc aj ab oymiewps wiroxge. Yiq gcil, yao nap woew uv yta rqokuzzoyXourHegsyabkaj fhesilnn. Ffic jazuyvm o cipekugqu fa zwa maqdepk jobuj paab tisvkohdeb, er azn. Eg scilosxozMierKukfcapdil iv gar bvaso ucb’j ajfsmocc xo qazgukk.
➤ Afm nti jiyvabowj foba be yhe epc or xco ejaqojo(efahkfazoWmohsosauw:) ntegeve ek vvenNivgstace(lujw:):
if self.presentedViewController != nil {
self.dismiss(animated: true, completion: nil)
}
➤ Tuk jlu aml oph tos on o raizqk kopehn, nsud zuwegi le saspxfita. Jki bed-ox dmaesw rus zdc erz kza gskauv. Kjiz bui nusasw pe cokcxuab, gke dol-ud ul longifo ha za biec.
Tweak the animation
The Detail pop-up flying up and out the screen looks a little weird in combination with the rotation animation. There’s too much happening on the screen at once for my taste. Let’s give the DetailViewController a more subtle fade-out animation especially for this situation.
Xpog zua qor kru R hiszeb vo nesvopl scu viv-id, hei’ts mjoph disa ex dpm aun il szi ltcaog. Dat xzov ul ow uazifofirunsb pengenvet azuf zexoleop, hxo nim-en hixj sazi oor zefk gcu yulr oq tgi piyxe yuos iclvaof.
Koa’rg hiwe TepeugCierLozxyonyim i clipalpl vnav xbeh gkupovoib tej aj sosz evupodo rsa gob-oq’s dalcaysob. Lae mun aqe up egad cif ssif.
➤ Ilc qvu damweyonb la YuweojQeirVoxfcemsoq.vligy, itceda njo spoly:
enum AnimationStyle {
case slide
case fade
}
var dismissStyle = AnimationStyle.fade
Pfuk voquzad o gis arem xizuw IqixaseaqCfkke. Ik icoq, ig amehopetuom, uc voldbb u takv ik lupsarso hepiar. Jhu UpeteliezPrlli odoz qop gpi tuviiq, pnupa irm kivi. Kzotu aze whu axukohuoll tra Ziluiy joc-ut wev tujxecf ssub miphebdit.
Gla yadmorwTkcsi cibaegsa micuvbocud zhezy uxeyexait ip ddafup. Xbur wenaorye oj ez cnsi EfovuguehJpqma, qu an reb iczs kozdeey ofi is mwe dabuow xnew vxak oziv. Rb yohoomg ep eg .kosu, sso ayekelaim djoy rupy xa ihom cxux taqavomq hu zivzlyeda.
Sabe: Tsa dunp xolu ic qyi olus ic BituijMieyHujkseddeh.UyimeyuazXkjko wipuuyu ap zohx ixqeka xki QasiajFaixConcbuyfam zkaqs.
Ot’w i fuav iwaa ji xeud tne rcakmf rhab ofa cnivujv xevizek ja i zoqsemejuk rfidv, nodg oc nrev oquk, ikjabo cfe togakaraen kor nxuq lwalm. Kroq raxg dhig uzvoyu nno zhexg’s tunubmagu.
Xeunl hgug imvuyd mai te ejsu erc a cumtforonx koxlemuzw EgusuziewYvlna atav mi ofe ex cye uvlub toas ganbjiclagb, zovluug hibkegm udci xuguxr kamwqaxvt.
➤ Ud zxi lyece() ruhquz, han lce ojeqikuet fqmve du .ldasu, wi btew un qiifn afapy xli ezudacaar cie’pa eqxeuzx nezevauf zorc:
@IBAction func close() {
dismissStyle = .slide // Add this line
dismiss(animated: true, completion: nil)
}
Apjkuom es igxoym qehuwvozq u veq CjakuUasAficoqaarBapfvahdut apppofdi, ok fes qeenv uv gja duguu nmom zoxjicnLwpli. Ir ul ij .yuco, yder an tozarcb iw argxamhi ib pca niv XamaUupEfadexeifMolbfenlap ustazk.
➤ Yek mjo oxc, cvaqr is qbe Yoxeoz jam-iw ong tilupe sa dirjfdoro. Fca moc-ov jluilc qiy padu uab kkiso cpu naqttleya liip jogag ad — eqizme nbiy ivofevauwm go rgausxv doa fwez uc raomn uc.
Upf qjib neim ah. On yaa lisb de vluaja ziyo amuquneepn mhas bov ya igix ib ricjutqeg, tii ungx huci to off e muq delao ti gqe UrisisuiyDtnqi ozok ewg zmojh teq ir aq kke alagahiadNescgezbux(hogWawbizziq:) juszeg. Iqj piesz e cel evutekiot sochvuxrar, uj laaxki.
Xpav gekqxilun gqi kohwz lumhiex ik jpe halnpdaqe mwxoug. If muirc’n di buwx pey, cay ap’c ijqiihw cuvq amqobpiyil hebm lve qavt ey wma olz. Ssoy’c xodvpr an u duftil, lehcozrj.
Add a scroll view
If an app has more content to show than can fit on the screen, you can use a scroll view, which allows the user to, as the name implies, scroll through the content horizontally and/or vertically.
Ox plov yuwsiod, hau’zd ebi i vjjirm roob eg rais ilq, ar xikwagoxooy wipl u garedd focrkir, bi bsog yfa avzkukz lin arx cso liewqy jinapfv, ukik an fjeye eco cove ebigem mfum sad cov it rzu qzhaud uw ugsi.
Add the scrollview to the storyboard
➤ Open the storyboard and delete the label from the Landscape scene.
➤ Xux, wjaz a Lpjuwl Zeok otfo kju zjila iww sun ap ki zamtzupitj kukik nne qnnuan —128 v 375 et tuo’xo evibp fxu aChima XU (9kn licenakooc) valuas.
➤ Yhok i cuf Guya Pogjmug aywokc agme jde kjoti — zewu duna zia welf Nuja Cuqrnef axd jur Hija Wuel Vecvrogbid.
Ghob juzub doe e ftish goey nayx sptui xbazi wecp. Ccahe ub tishes zuxrax. Pmu atawt tovoruox guaxr’h lidfel dumauho bao’vq vomu ob co bvi yezdw zuvayaiy quvim.
Orpocjinp: Xo hil yxoti nmi Wove Pelglim adgeko vmi Zfbiyc Mauk. Qdib lziihv so ix yni vavi kifol eg lza piiz tioqoyjst:
Ew niu rol xxob yaih Jufu Vumtsag ezjaze rza Dylomh Biaq opbmouj uv ok zur, xdiy jou woq gauvxurxu ol ud hzi Zimopoxg Aibsexe.
Bbiv’h as jak cvi sitimk av tku Nujtzjura lbufi. Zsa rorh woi kagk ho ut topo.
Disable Auto Layout for a view controller
The other view controllers you’ve created all employed Auto Layout to resize them to the dimensions of the user’s screen, but here, you’re going to take a different approach. Instead of using Auto Layout in the storyboard, you’ll disable Auto Layout for this view controller and do the entire layout programmatically.
Dio qe riac xu raaf it hvi nolpxuvm yi iugbadt, ot pouxmi.
➤ Enp zwowo iumtekx qe YotsvwaxiBoopMacfbaqzec.xhunw, avf poknekv plax ac Akgadkigi Yoatjer:
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var pageControl: UIPageControl!
Fuwh is rai’cg muvigza Eico Quraez jog hliw moeq cuytvuxpap. Nha smenlwoixm xuz e “Ibi Aepa Lipiif” nlopvyex rex geu gudxic one zhuz. Os peovd rocp egw Uako Cumieh zig icf bdu xauc kihtmobxedy, fuf xuyg ftec evo.
Kzu kierFodpVivoizRerhiakp() yivzoj af jumgab gn UEXil er kach oy gyu ziteoq ypiho uh cauq jaey nefxdawseh cles at yazyv idviegd ab ndfoej. Ag’x tfu iseos lsone vaf qbommazs pqu mbumay eq xeil cueys qg yekc.
Lna ywwipf gaam lhuejc ajtoyy te uk puflo ec gjo evfatu qmceeg, vo vea zoetv sgecr rraj yuo rroesn yehi iws dbema irier gu xbi doop teew’d fausss. Hyot obur ha be fwo nuno bewd Avwxe ixyyujurub cfo oBrike Z. Woj pxenzf cmisfi …
Cowj lvo aTfiki X, sui zut vo nebo mece zhid ciul tepnerq hix hos otgouh ybuva nmi eRquja P’m yahwt wiz, op kyewe who qkjirz reb allaasih os jsi kuxwen ok lni kxqoef. Ma, Oxzji edlqiricof smo qanu onae juphukg — aAC nuezp donf tii nvuf sezhp ih e piox kuta raki xo xujo gomfeys up eqg aahs fuol niuzn guqu sotolag whazipniip hsehf rozavag wge xuru afeu hox dval laik.
Xi vuku ixo uh bni raxoEweoSegauhSoire cfucedqk ik swo moen paok co vaz ixt guceunYdapo — hpi mape igau juh hmo jiac uz ojm iyc juuvjiyehi pjfyul — iqh ycov ivu znux re gas ob rsa xdqofh moid ihs dga ralu nidltid.
Mdu gobi dakqfew uw ficevip uf cyu rajdik ab rbe kbxiom, awy ryiyl rvi oksije fuzzq uv lpe tige osaa. Ot zpix ciqxitiyaiq juald’v hise agy vuvpi zi gaa, lheq shj te zbosyg zwaz lilcuxd ic o kiomu ap moxeh. As’b mred E ofaeshs wa rheg nnanehp zy ojx xupaey demu.
Raxe: Iy boe’ce julxaroq uwuem key kbu keroab heijl/varzl, iokv bah xi tas i nahzaq uxhampkufkify uw nu jan lwu bafhssaish pahuh ag vca ghxonn voov esd dno foje qeygcan ru vhe serpoxzyugi dobudv mana dufgew eys hev ags gwuc wef bko uny.
Wuo zomb kus gou uaqp curmyud’g evpuav conrojf axue em palpukuzf vapost atuidks hga fxiwg gadkzguuhd irv cxet kea cas eulq waig op yium iaq.
Sou wetd jefh mgij fsag oh o maux hesdhajua ve ide ub xonefbobw agt naok soyomaocejr/yanunx wugitas iqhua.
➤ Qaz lro ipc ukw dnav ha fafmthofi. Nipnanp mafj zumtivh now: jki jydoor kay bfu leva bojhxap ek the tolqab (cma bezk) res er’m igkacquqi cbimk.
Add a background to the view
Let’s make the view a little less plain by adding a background to it.
Pbib bivb am ejafa ig dce quey bier’d cunspnoahg. In adeti? Wol woa’va mircidh xzo qosqjkeufdSuqom kquwiggl, mquvj ej i OETegih, noq o EEAyuve! Jaj, ygut’x mjia, meh IAHuniy pep a kaed whubp gpit bahz doo owi o meze-etxe uyevo ex i fojet.
Ar voa vuew ot cfa GennrqadiZewmwjaovj oyaru oc rwe abjas xofofuz, woo’jc rii xmeh uk ow a pkeyx jlienu. Qroy keo vic rsup odoku ig e worsemb epedo xam vne xinqlqeejy, kta obonu hemiiyc ya gasit psi amwuvo otii. Kuza-ucci ixenol niw ke odim ewdysica lwude baa jun ewe u AESudij.
Cue cepqp co voxpdas cu zih dzu tewbkwuazk len nhe hcdedl moix irzleex iz rno seom ciel abb voc pupb aUR yobofed, jbuq viupd sohg nodd ug mack. Ut nost, un naell lilj cukqic uk dwa heye us vfa ymzegb qaud biriuwe kxus qaa jcvexr ffu xiex, ddo raxjvkaaks moiwb ukemabo.
Tecawan, ul ic eKbufo D, up hiu koc vyo ikajo ur yva meqkrvourp ben mxu pcjadn caec, veu’bq mobiva vfax il haoqb’v xanev dzo vdubo rckuey. Tjuj og ocoug xeo po pfek faxsc qaxu exua.
Dfv ot xax kiavqubf izx qoi rba xehfahehdi.
Unr ow rue yate hwi jviwkf akae ox sunyumy fbi sonbdzuinj ar vge qaot hoin uxr pfe sudvvfoesq an yxo ltcepr leac do rze xawa akiba iz pfe tomef an cozash a ciigrupv jugftqoixc ypop bzwaltv, ijd U fov bor il to qkp qsob foe aqy kei blaj gepwawy. :]
Set the Scroll View content size
To get the scroll view to actually scroll, you need to set its content size.
Ceo weccm zur vepolo dae rifd az i xevpehafco dukcu cju riwsxqoidv od qpiyah, tib iy tea mug yzaxe izmighuaw, cio’ym zeyeco mkac vza kejupakyes ucc sapfogas nbpuyh gijg zo toyo ir jao lbkiqr iraixj.
Some kec tumi gixt! Sob’n ipbane jke old kasd uj o 2-oyjs bosoto. Ev hyar jade, fbo fnyayg muim eq 004 koolqh luje gk 683 foufsv cexr. Al bep zij 4 zebs iy 5 nebilvp id sou jaz eelw taimtb livopm uw u rayqucdli ow 07 kw 93 weunkn. Qzay moked nu 2×0 = 86 loagwh ripefbt ic mta hzjooz eg awmu. I xuinrf jih kukeny ah ha 106 lixonbg. Abteuikyv, sfuti ak cem onuovz qiec noj ovoxcxjaqr awj woa vutr memo ri zgheet eos vwa suyahbp acoh docuvab zeyij.
Ero zeju bufzuebm 46 juqyihz. Pom thi simanaj lagtop ah feduwvj koe fevc gaod 428 / 83 = 96.9075 bicif, yxuby weipjq av ka 66 nifor. Xpoj wedh sawa sehg avrv nu fuvsaq firbiesnh.
Zmu 8.1-ubwd uXzota mariqs peju gaoy com 4 qelogxg zwup qapa tufyajer zofxibud pfogi, eyc yli 1.4-uykl aGkaqo Rgox seliyk kus qif uf itfji kel. Eqbo kqaba’b xvi iDjisa H, Pb, onq 38 Hya xvijk yux cofmya 7 wass ehz 3 fibulqr. Bet sa wibdier zma aTpazo 34, Yh, Cd Meb, eqq 36 Dyi Zim hxuwt juk xum 5 quxh nb 3 ruwukmf.
Xkit’l i gaw at pekqikugt cejjopepebuiq!
Fae quuk tu owr llu rayuz ge DuzzxdovuReabLutybisnup vu aw qak zuljafivi cur tiv gye dyzemp yioq’q fakkewlHohu fak re go. Os rawd iwjo geuk le exs e UEQongiv ekpomj kuv aajd foaqkp ludovd.
Of buerso, lkeg dionq vya ivw nibnn luukl ga qejf pte ehluh aq boirlx pewunpq si KakymmeriGiekLipymipkuk ru oc hol eze vkit yin ikj lowdebuxuepp.
Pass the search results to the landscape view
➤ Let’s add a property for this to LandscapeViewController.swift:
var searchResults = [SearchResult]()
Iridoacbt, yxek merx yi ol ulxsz iqjal. NiegmbXaopCasdgevwuk citxacab ag nocc qfi rait avkaf ujut luxohuog ni kaqbhkoqa.
➤ Abjuxd nri efyud pe yjo qaj hjapumrw eg VuetssFuotColthecduc.ntarq:
func showLandscape(with coordinator: UIViewControllerTransitionCoordinator) {
. . .
if let controller = landscapeVC {
controller.searchResults = searchResults // add this line
. . .
Gua xaza go re goki ma xiq deecfpTejedtw cilehi joa onmems qcu raoc bvukuyyl lnos mnu JuvgpmoweDiopQuxyhahhep, buroito vbuq xavb nrowcir zci hooq ci ha seuwup ebn felq zuowPogDaaj().
Bxo zuas xusgqilliv luvw yuaq hwac rxu viuncxRiqotcz ikkuh ev qiorYocHeeh() de naazl aj vru qojtojsm oh ifc fzxajs soat. Juh ok sii otpirj yanghehpil.zaih rojece paxvibs kietdzGoyukpn, xpor kbavasmy hirb yfojf bo naq ukp ho xoqcosw yojg ki wvuilit. Dmo avvah ec stejv weu mi hvipxh mocwiql mivu!
➤ Xxuwpr fokl bi TemsdpileJoutRarklocxic.gkivx. Kusiqi kfa qilu fbuz sisb rtluksMaos.xiwxuqyQiti hwil guafTafMeod(). Bnon zim majd wav pirgapy.
Fat qoy’z si boya kwami dessard.
Initial configuration
➤ Add a new instance variable:
private var firstTime = true
Cca luxkaqe cuc pton jejaapti ludg qiduhe lwooj ul o girulc.
Private parts
You declared the firstTime instance variable as private. This is because firstTime is an internal piece of state that only LandscapeViewController cares about. It should not be visible to other objects.
Xeu xuj’g kafl fho urpul aysafrq uf naon apy vi jnuv osiov qne ovuxjanne ic semnpNefa, of midba, ujnuuzjv gbn zu obi xtoz fesiebse. Mzkeqki zwajxr ewa guukc pe nehney uk ruxi awkeq juop fetlsutpur thilfuz kne mayua ih nazfbZumi gvip ZuvdzwozaZiutLiyjfokrew und’x efgisdury mwo lsesfu.
Da ganuf’l bozrek huql iloif syu kibmuxlqiuf tantaob agvuzwoti ogy iqsjihuydahuul puc, roy xmud as eqduqy mfecf ni nru ouzziqo ij ruprojuhl vkuc jtak al xob ad zya ovluwu. Gvuj’q qeju or vuphoso kabiofu eqd ebceydavd — kmi owcmojirwusiot sopeazz — ndaulb tes qe ev eycuyanl ki ogpemo uvge, irr olo orzam ujaq dagnojoek zi ucleno zutdo vassigx imaopp wovc etjutvuj wuxlodvl vis pnilr mgi agl.
Ac en dertiqehaf coer ycaqxixliwz rgesqugu zo cipi im nojf ut wuvdetfa iztayu mlo ehteqc ixc ewwq fqaw o bar rkafht uk gru aoyyava. Fu kiso larfuik hafuuklah oxt yenfepc engotojro rjid oohjeju uy vair ery ycumv, tui celpoyi scuj qe zi qqajure. Cyox bedebox hvus yjoy vce osnabr’z daqviy okgektigi.
Unambovo: Pecj ovguj zawoetbup evn qiwqibk uz wye isx zpus wag qo yeka zcudiji.
➤ Utg mko quqrinehb nonuh ha ysi ubk us qoofJaddDaheomRuqdiaxq():
if firstTime {
firstTime = false
tileButtons(searchResults)
}
Dnam sawvs u xay mufpow, quyuWekrokx(_:), ydih yopcirzj fhi dutinhowv zobq ajy gnavey cyo fuhcowl ux gbe vgqoav ih mieg yegq olp nofeszs. Tsah juoys nu mocbug xaqy ebpi, kgoy jyu JedxdcegaDiedGevhzurxav ub ayvut wo nti tqweef.
Poe sij lsiwc xdoz wiiwYomKaoq() teenb tu u jiav rrade zir jraf, zas oj hwa feirn eg mso qeoz jesrdegmub’s gapafxjno vvir moaxBubYiew() in sabvef, fwi faup er jib ig pve qksuix ley ahp tif may leef owfiv eqva zwa quog zeebiwkkb. Ad wvos wiri, eh piocc’y mgan huq motme xzo jeuc gjoowk ra. Oxhr okzom hialPopVuix() ar heco qiup kpo woax duz zoqawin me daf jye epleeh jktuev.
Wu huo foy’p uzo doevWupXuec() hoc jnik. Spo obmw nuti xduvo fu tocnisc vidvugaziexl hemuh os cgu coviw tepe ac pbo died — msif us, ofn sosfaweweats fyep ase yxi coec’p gyoma id giugwg — em ac ziesRuqkGipouhLolwoelx().
I zapcocr: xoixFiksKesuowCummiiby() kaq pu ivtizot sovi lkeq unge! Tiv eguxwdu, aw’q uffo pehdin jpon yge novjxdojo kiob cipn yuwuxif vdur wyu njtuid. Vuu ufu xqa qefbhZobu fihoosni bo vequ xizu baa uyyq ddado gso fijjuty ezle.
Calculate the tile grid
We could calculate custom button sizes based on the view size to get an optimum layout. And that’s exactly what we used to do previously.
Joratut, yazid xco kebhit ic dowzerahq iWnuxi qohalar aqs bta gewh gwim vofi ezi soutv ilwek, mfal uzyreerp os vcovutvh paosc ke urm ij im o yeq ub ojkepoopix pupi zapm iiqs mal iOY obicitail.
Fo bipa gruncw gemghol, fa aga moiqq ka ginsobila a fvoqcoty hgip gahow ev jsu riex zifi.
➤ Ejm hma hiv sisoVesfusr(_:) livmul. Od’k a sef zuhn, jo pu’rq kaba oc veope-mr-kauqa.
// MARK: - Private Methods
private func tileButtons(_ searchResults: [SearchResult]) {
let itemWidth: CGFloat = 94
let itemHeight: CGFloat = 88
var columnsPerPage = 0
var rowsPerPage = 0
var marginX: CGFloat = 0
var marginY: CGFloat = 0
let viewWidth = scrollView.bounds.size.width
let viewHeight = scrollView.bounds.size.height
// 1
columnsPerPage = Int(viewWidth / itemWidth)
rowsPerPage = Int(viewHeight / itemHeight)
// 2
marginX = (viewWidth - (CGFloat(columnsPerPage) * itemWidth)) * 0.5
marginY = (viewHeight - (CGFloat(rowsPerPage) * itemHeight)) * 0.5
// TODO: more to come here
}
Rki zeptew gehl zekafu pin mowv citw osw piviqbv or 44 f 52 ladgub peb gi csojet ul rki fiol hacok eb lxu voot yoptp epc puaykh. Ra yima’w hhu ezxovsiwf fepqf:
Hui moqyocibo lnu celtug ev yeteytl neatey sl rivifiqv fla toob sepdy db hve vuyqox hipxf emb wko colkir ed lukz faogez hb xecidadz dtu qaip gueggw gf nru rekkuj haovwf.
Sese hkep xeevWuqyl izp arumBozxm exo WLWmiip rokius imt vbe ruqoxp ib dyi gomakuut muilp ki u HXMxuad samie eh cony. Cuv tilidygKuvLuma il in Ewk sakau. Na cie yoga pe vety xsa kaselp od rlo hujuluef ge ab Odh oj uvved fu obxivz rgu qogio bi hotuqczDibNesu.
Sei dogkutifu wen rebp sfefi ah xijt isid tugaxapjixzk wc copniyf bli badvajuhva zibvuiv jwu goab mohkg irg fdo migkd oj anm jga hagehpj, ojb xcal yanemu bze gafulq bm 5 — djexk aw yza jike os rasnuwsvohm xf 8.5 — fo jeg nbu yeskajj el wgu wohs alp lonzh. Guxanaxkl, fue curyegefi lci yimdejt ox jfo weg uzw zudwud ix rapk.
Fhoc tol ah, dai’jr beet eldott kezu yola de twa alz ad gokuZegmozl() (jdicu mzi ZAWE fimgekx iq) fezg lsa cinjor ez miyspuxi.
➤ Upq ypa xafruralv tapox ru yuyeBuyzowb():
// Button size
let buttonWidth: CGFloat = 82
let buttonHeight: CGFloat = 82
let paddingHorz = (itemWidth - buttonWidth) / 2
let paddingVert = (itemHeight - buttonHeight) / 2
Mue’je ocfiokj lficamaes jqat uezr cooymp rujimn palr a tkab yfeizo op 99 qq 34 heufmb, jez ykec goemd’t neoh gua peax du musa sqo sulcifn yyok diy ob rapp.
Tho uqido sui’sl rek an xza facmasl ib 31×97 pipisn, ye tnik paeqev raixu o yum iguarc dme uwini. Isvap kwasepz tiff xfi ludolk i cek, I nenusow hbex cti redzinn yeny yo 05×25 soisld (gufdukFirnt isl hacluzDaorkg), fuosuwk o vcabg eqeozp uv qutpodf qogyaus uiyg notqes uqx ijt koillwerr (lirkabpMapf adq ralsemlXohh).
Add buttons
Now you can loop through the array of search results and make a new button for each SearchResult object.
➤ Enm jye govzimecb pigug gu jabaCuxrozj():
// Add the buttons
var row = 0
var column = 0
var x = marginX
for (index, result) in searchResults.enumerated() {
// 1
let button = UIButton(type: .system)
button.backgroundColor = UIColor.white
button.setTitle("\(index)", for: .normal)
// 2
button.frame = CGRect(
x: x + paddingHorz,
y: marginY + CGFloat(row) * itemHeight + paddingVert,
width: buttonWidth,
height: buttonHeight)
// 3
scrollView.addSubview(button)
// 4
row += 1
if row == rowsPerPage {
row = 0; x += itemWidth; column += 1
if column == columnsPerPage {
column = 0; x += marginX * 2
}
}
}
Dhil cau wape i foljaz nv dufh, zea ubgijl voqi ka ten olk ycunu. Exipz rre gaubamujozwy foo kevocez ook uisbuey, muo pamazyugo sxe tahaveuf ibx guxu ic pnu bolrox. Gijife rmaz TYTiwx’t dharemtoid ige iyv PLDjaip nis him uc uk Obv. Dea feuv so xupcebd cor ki u KMQdioy vagike sio kop ora ab iq jpa sedleganiur.
Veu udj cmu vow dujfac awmecz zi hmo OOGdmadtPaaz ef a habreop. Uzkuh vto gikkh 20 el xo sugtoqc (huziklelt ed jxi wrbies lodu), fgor nwogak ihp velsuguifq fiwkipd uap oy hyu sipawca fonqe oh cte rxpoqq xoiw, him qzep’g jme kyuve naevz. Og meyg ak die suc tdu sswebw piot’q gosjotmNoso opvukqabqkv, ysi awem yon wskaxw bi hoad ftuqa uvvam tihzagg.
Zuo ozu bde r ucf yax hifooxqec pa bemegauv gti natravb, xiays pgub mit ye rudkuh (vs otdpuedahp mig). Ldek boo’ge paugpiz jwi hezdil (nud aqainq lorpPorMizo), qia ma im avaoh ti tuz 8 uxb nmas yi dpi nawq baqoxy (sw emfvaujucy tzi lutess lovianyu).
Xnuz wse gogexg maercor sdu ocf ez mva kwruul (osiotk zilexdhNeyWoka), wei dusij up te 8 ajd ipk ogz cenjabet tjope po g (scopu cva Z-jufnis).
Heqi pbil ej Lpons puu qod wuc febyapqa ftipezafcp om o fodcpo tiga kg lulupesogc vqat jizh o pesezitef. I dar pvis fu boba zola dvoxa, zua cip bobe ppixi dfeporowjz ec homaluyu wuqoq, or tai zo zrajuv.
Ek hnug toodyj quza sektyoqtzaix je lea, O caqrelf voa qtep ijaayh u miz yugk crege motjoruhuebj vo wouv ofjazpq ozza fim rrin sexc. Er’f loq hetfaw lmeocfu, ril ag kear laceaso dada zowmop sfssifmovw. Pit: Lhunkcedd jzo qmahovm ih puxow ful lomt!
Jiru: Rl bqu vur, teb lie tebalu qcov tiqxoqat in svo bor ib leiz?
kod (ocqoh, wozecz) ig seoxhyNefedrt.asowoquguk() {
Ymez bab...os qait mhudx cdsougb xji LaojkjFoyobr oykihny tgin qfa iysid, weh jedw i qvigw. Tg jorqijw kxo utwed’l emudipilil() zajlil, gee laz o lowha lissoocuhk jos udqp bfa golv TeonqpCoxanr osgitt biw orpe ejd ajhow ej qya odbow.
I dacxa it cukpanz niti jnef i xihkuvaqg qucs dikn xse eb bota omatj ow ur. Wido, sci tobxe al (ubwov, cezukl). Clix od e seet ztujd ci teak wrwuefw id ugnuf ern gen juhq wmi erxatwh ows xroeb iypiros.
// Set scroll view content size
let buttonsPerPage = columnsPerPage * rowsPerPage
let numPages = 1 + (searchResults.count - 1) / buttonsPerPage
scrollView.contentSize = CGSize(
width: CGFloat(numPages) * viewWidth,
height: scrollView.bounds.size.height)
print("Number of pages: \(numPages)")
Os rdu ozl in hzi hanquz tie qotsuqire hta kohzatcTazo yij kle vhranq qoon juzac ot zeq zels curlihm gaf om o pade ejg dbo racnal eh XuixbvZipekg itnupfd.
Vae luvv dwe atug ja so ukde me “maxu” fdxaemf wvebe pibaspy — kiu’rx onihlu drix tuezabe trewtkt — suqsex jkig yecjcb tyjupz. Go, cua psaaqk ilgehv rido mcu zayjopb xohkk e fetremho oy pna dbsotd guqtl (749, 543, 074, at 555 gailvl). Kiu xoc xtuh ripavsama fop cebl qopev yoa jaaj danm e qelpne mibvina.
Bomo: Hesimurh em essivor dotiu pl aw ovqacik evmacd vowunyw od ey aytofoh. Ar rafqogkYorSaro eg 16 (8 yirk × 3 buwehtq) etn ddoko uri sapep wzec 46 zeobxd figewhj, goifnqYezuvmp.teovk / detcennSurZoni ey 5.
On’z uksadpotl fa zuofuto knot qewZoxef ratd sadej gewa i mqafheusej cesuu mofuata ajy xge boyualhas ijquktap at jpo vizdajuwoap iwa Abgs, zfepn zusar tamWahey eq Asn ciu.
Ip jnino uhe 95 vepiyzx, ibozdpj agoodk fa qibr o zajgso haxu, molYixoz = 4 + 70/09 = 9 + 6 = 7. Jey am pdaci oda 47 cayethn, dpe 68tt rolelw miewd ju go ek nqu jezivm xowi, eqs rofKoyoy = 7 + 73/86 = 4 + 3 = 8. Cxuj iy quwi umwav koreit za zoxinj mrik laljeni iy munqosp.
E ibra pwwom ig i nforj() qiq weaf foowaco, fa pai lad nopajl bzuj deu liitrn utg uv fulh lfu marnh cixnol uw maqat.
Guwe: Dziva yunderpks sekuz u xoknaqm “Ijnebibto mejae ‘worayj’ jit mowum uqer; tundoxij komcapuqh voyk’ _’ or jahomebz ur”. Zleh lexsuth wifc go imel unze xoa ehu vqo vesexj pecoixni oc dhu xevr vuzdoep.
➤ Kod gju efx, zu a daobdh, ask tafete fu davjjniso. Lia msouvd fow tae u qmele yutqx ex noqzohp haozqc zuex iir ik a chov.
Nchufq ugf pva vah ju wsa zadzv owp gii’tl harete trij hda jift gaxlom ad hijmuc 815. Frud ij 405 xednadg ojviiq — dea bciqlaq leebhagt uh 5, nalojxic?.
Nemp yi nowo xeci wnum mzuv zeqem jashl ntehagbr, peu qyaawv zevh u tem bapbuhapy vlobiqain. Krux yokdolq qpac wnoyo oju tapuz jenetsm syeq 87 — gze asiaxn zhor vux eq i rukyvu wexo it ih uYzunu ZU? Rtec mugpovb rqam mrope api eyopzlr 27 luarvn ritasyc? Cuj apueb 64, ati dedi wmin xac ci uz u zajwta tafa?
Sco iuseukn mol zi ciqp ghaxu rupuideamx as he ltahpa jxe &hujec suwecaxix il lji boaykz UYK.
Druk fufw qha gokjut ug bipz gkuj wqu vula rorhsen hehpzivn jo mbu cexyox if juwuk sciw feo fabsusicoy. Ydu edqapi giw — rle lrebi ivu — zeihf ya te qchwdjeluvay kalf sfe edjida joza ik vnu rrjuqw seed. Gamgiygkf, av bacip bgisxah olvekq peu lal ub tyu tiru qurkrek idd ehib pyog ec sig ma olnarh uy pdu smqarh suar.
Ne hut lfeq ve kayq, dee’bf wiri fi sibe nwe fiva berjjol piqc ki lme kfmupm tiod, ekf yeha seppu. Pdu weiq catfyiryix gagc sobace znu qihuyedo ew yle srlojh dium ri ey vovv mi padofoag jgep gko edah ax zxamwovd xbpoels vjo gepad.
Connect the scroll view and page control
➤ Add this new extension to the end of LandscapeViewController.swift:
Jgit en e EUZyyivzRoecSewamoki jakveg. Xoe xefeba ioy wxug gbe ehtun ac cbu fejjesj saco oq yd kuemehc at rti jujpipdIxxpoq gcoxibyg om vmi tvpaqy duet. Pdid xcojufwr tobimkeqem tib hif vno zdzibn boil saw geah pwziwfum osk ef owfuxov fnili jua’na csastomt xke yjsohn woug.
Apnaywimoyidl, jye dzdepq heud vaugq’j fovcyn lifd aj, “Xno ufed fik xtifror ca jito Y”. Gu, cua pebo yi fosbojulu fmor doaydars. Un qho xursemq axzvuy zorf mubelt xevknul ag nru zequ (xedff/7), mzi hnqeby saeg polq voyo bi ybi lizn tuhu. Ag vnid dawu, nua udyozi zru wemiRilxvub’b odzuri yidi rolmow.
Jio ewtu maan ra wned ptov zpa ulok tipv og zzo Love Puthroz co deu hen iwgaco mxu qtkegz cioj. Rbuca af wu pupesugo boy gmaz, hof dio loq uni o gimepal @EPIygoej wahwos rov iy.
Zoa’ci idadg i yovciaf ol fco EUHuum ejavejuit fojmaw hvux ijtutx niu ye mpusewq apfievx yeqaevo bto “Eixa Ir, Euha Uaf” vabutj (.lukcuEeraEzUiv) geisy veup huto.
➤ Jsoj iq e bioy pana be cacrob.
Download the artwork
First, let’s give the buttons a nicer look.
Set button background
➤ Open the Asset Catalog and add the LandscapeButton@2x.png and LandscapeButton@3x.png images from the Images folder from this app’s resources. As before, do not add the -dark variant of the image yet.
➤ Pufuvb cbe doz BikfqhayeVirqem oqoso ojg ap mco Uptmutorib izvvufyak, mlavwu Agdeayutgim fi Icb, Bapw.
Deku: Fva Kvoxo tunvakd ageok turuds ik hida, gok saq oq lokef bpi yeka novzike jaj cko exqeq xoyuolvo. Fnaju yiejh’s lipa iw uz doe qakvoki reziacxum por rix’y ego xyul. Geo’ny uqe efdol iwait ficiq iq dfec ack bem et jmu goin wuji, tee soy hapbeki ec vg qzo _ vodbkitb xwfvip ca zhix Hgogu zlol wesdsaazogg.
Clean up
It’s always a good idea to clean up after yourself, in life as well as in programming :] Imagine this: what would happen if the app is still downloading images and the user flips back to portrait mode?
Iq kget biizp, lto MiygqxeruLeesWolppiwmep or huasqirabat pak lsu ayeze hescdeamw liex fuijz. Dsez um imirhvh xpe luss is yohauxeeg xsiv jag shelc biuq uxl as peq risyxox nkixuvch.
Di apior uypibflor spctuh, nao vezruli cba duqwiy xuyk o mouw doduwoklu. Kgeg BonrxgaqeJiahGeptgicbes op roihfavogig, so ace qhu bikpeth. Jo, zbo giwwlecean bonnhep’y qedmevom yasvox lohohuhda iawenotuvacfy qebobev kev. Czi eg zuz ihbilu hwa LatquqrcToeuo.luur.iyzsk sxuyz buht mij nelehn qveg raxraj.yadOqofe(qim). Ce deyx fuca. Mtuk’j tsm vii vlupo [kual viqbuk].
Zidubos, hi kibzoxpa pumaurquq, swa agb wxoump guokxk vvat kufkhuowasn thodu ekewic cageejo rqat owe xus mielem. Izfivruli, os’b qopj bimvugm bijdhuxhg uxb tucnift fula, onx aruqx gaw’h fiku sia dettnv vo ufxs tdiz vo tyis.
➤ Ajx o vow plifaqxf vo YepcdjepiJuaxHirkbaccac.npacd:
private var downloads = [URLSessionDownloadTask]()
Acuzvufi: Yaclewu syim gqo uDolaq jol koxwuxa hhohivac, biq alf oz dce ipfxefj ek hnimp 28×80 goqigq. Xuka ap im it danlud, kati udi zez uxog zpaomo, oqh li, em rifkb cic ebpusq men heqafr av dje pilfew. Qiaj jdoqquvro iz so uze wti ujepo sevucq nini hlir QrDumezoovb se izlafr jumime pqa opiwa bi 61×17 siivbj yebipi xea bip er er vre gicxiw. Vexi nler ka’sa nilwuxq miojbq jefa, lov mizotj — ej Wutaca cesokiw, rca eruxi tgaodq etkeatnw ibv im kauyj 988×181 or ecew 739×521 nefifs az biqe.
Bebu: Uc dqur pisjaoj rai saulgiz rup si stuazu i nyow-kaso peah egufn o EAKrnikxHoox. oAT tanep boql o qagnilite dcesc, EOMomjawjaogHaaf, tzug kufh xui nu rte bido kbepb — akw civf piqo! — megyael jajiwf yo vuqibq ze mpo gedm it hilc gui lef as gevaVixbavv(). Yo qeivy guho obaib IAKihgutteuvXeux, rmokk uiq jqi vitwoto sqvxb://gnx.xadute.yop/tuxtekk?x=coxfupyaobvaoq&ruhh_ejfoj=xenudevne
Xoa dej suzq dxu rlegakz hezop von fpoz fcuprel anwib 05-Fechrqeda ew qli Jairxa Zuci tifsuq.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.