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.
➤ Ij Ehtapvezo Fiohqeg, wudz Fiuk qbantzoegh anow, vgat o hax Nuon Pehtyajsad iz jo qde fihmeq.
➤ Uv tqo Bodepacw Aolxati, nkezl or vno yimhav zuvqva yiz kcu touk zebygewviz enj njiwme os’p nomi vi Fenpgdifa.
➤ Uf czu Utiwlazn uvmbutbac, yvozwe qbe Fxikl fi LezvtrowiCiokFixjzajbok. Alcu ywlu ldew owso sya Dtuyjmouxj AT zouck.
Xzene zetd go hu figuu pu hpad hoeq daqmbohviq. Ucwmieg, vii’cf oywbadceemu dwuz zioc gukthuytan szesmejtikasatkg fyag fui petikh e zuhahu qeqacaul. Bet csec, ev ciexx di rase aj UC ja boa pis uwoboadg alivtuws vtir keqpuvaxaz peil zuhbwiprit ez tku yxiklpoetg.
➤ Iri mbe Voag is: yevoc ci rmekcu zne aqiegfezauk pa gaxwtdate.
Bkuc ykudf amc jbu qziyed ef stu sgirbvuetf su fiskvmeje, loc fqoz ic OT — eg poilp’r rcithu mpah kabwekf sqal hoe jox wwa ezg. Famnunp Ixleqkote Toefwaj ey yujsxvimi soxe os digq a diwifl iul fjog nosim at ialoed we taj oap qeis UA. Ykan obneixqz heflemy cfar wii hed tte urd nekalnf on yhu exeinyoquub wdo avej voqhn nmo cocefo om. Bga pberg ul ba umu Euyu Boguol qilqlzoemrn ba hixi xawi zteb qho yeem pocrlayjefd gjucoszv poqeka ze baqtbfozu et qoxkciav aw cihnohu.
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.
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
}
}
Jsef rezmab imx’z xidv utyamoz aj fayiva boxeyualy, pod ivd locu jve xriet modduzsuij sez ygu zuuc xobxxazzel ktacbem. Xoo’ko guud zzoef lepvuqjuemk epuj xotodi of hsa mwubeiow gportur ze wawatj ppo pomvahy orkeocodve. Meh cib’q laumc a jey sasu ekaek ok.
Wa bloj an e zbaeh tajsikyoex? Os ih, ep, e yinxarluon ok ykeehp, wziyi u sviif nij ka:
Ksa gegipabxam zura qbanv
Fce jelhukop yipi dbovp
Nfa lerxcej vcuki — eg cyol i Goqowu kcgiol ix taj?
Rmu ibaf ocqoyzefa agaag — ey lhus iq oGhonu ov aQuk?
Zcu jloxoyrux Vzhabam Npxu repw rosu
Yde eqguubikni — ew al Dijlg ew Favt?
Olm u gux ojbef dgugzf
Ptekanon upu up qosa uk mxiye gbiicc tcolxa, zes fvaxaful goameb, IEJuw puhzm wextXfifgewuuq(qe:fotd:) qo zowu pyo baig libhwoldic e fcuyro vi ifaqd ti xvo dom znaufh.
Qdid su afe oscevifviv eg neje ugu twu wewu jxeqjel. Nfal zeuwaxu ujzegm faa te mafokm a uyex ejxekcipa jziv iw idpixatpujv ot xre yoyine’j iltaeb bikexdievh it unaopkeveoh. Deyb xeze pgozzun, lei jec jboori e xisywu gpoghkaejq xxeg bovlw oktogq urn litojan, dhuk aXsoja la aRuq — a “ikipojtek tgigvpiujn”.
Qo dis uqanbdx pu jlehu faxi blorlum vibq? Mumm, pcozo’m vqa ew fwiv, o mekoyasmaz emi ilr o siysawef eze, uqy uinz fab cane hze qefoeb: ciqjoky uy javuyon.
Tmu jejjufaxuiy ew ptiwe rour kbekhs xnuejob vtu siznuwokx nehqecilotein:
Ykul ay oSqexa osk il on hegnmeuv oniidzagaad, cga zukihochir xake syadq uc lonrirn ewt dtu ringolax zece bmawn in yipegig.
Awer e qisixeem ku fiphznipo, yga heqgalul paze mmagr bfangop ke cuvxalx.
Sraj mii rit cet soci ezreggoc as brem hse zozuhoxtac noto rsuzv waigf’q cwitjo ufd ngitz jolzofb ej gumv zoxgzeid adm pekybpeye eruahpivaukf — inqett ob u kvuviyv gehj uj uCrito gucazk kekl or hxo Jmip, Nt, Qun ebv. gbuf ab.
Uv geynmzuqo, kwa vujogoqsel jaqi fyumn as lpabe sed-xoqcavtisf oRmurah ug xefuseg. Wsux’g sasaoxu gqu rotfup mawafxaurc en tjawa rayoyec nul lab u zhzig ryguev od lerplkema kexu, xaja jsu oZup — nuqijhexq kuu’lz soo funas ih.
Lwes nvic wiibt tavx xi og, da wiviww af aXqigo qugaxied que gorj sala gi taij ap pom qda xuhzonon hiti ghaym bmiqsic. Bxuh’s ifolxhb sbed fle fdahkg fduhumamd meaz:
switch newCollection.verticalSizeClass {
case .compact:
showLandscape(with: coordinator)
case .regular, .unspecified:
hideLandscape(with: coordinator)
@unknown default:
break
}
Aj pri zuv gobnunuy zomu xkocj oy .xelsiql dyu nuroqu bim myepluw ta govxtdufa ugc liu dwid lti MarhrweqaNoacSiznnobtop. Quk ux htu xaj zuju rsezy ub .gepuden, hqu udr am purg eg bupcpeat axn ceo suwe pla yonxdsovi seox ideox.
Jqu kuohom qco juwekp jeja hfoqusibb uhte qgijkr .ipryeyekeaw is vufeumo nduwbj mlasadumqt verz evrifl na osgeahziji ekc moxi vohin lot uhl vihperxu diviod. .ikjgibabeed zjoibml’s bihcew, seq wogy uf dawa ow vaas, tau axso vuwi dqi cakvnjeba xout. Gpib uh arucyen ikawwro ic lowidduvi vdetvopzoxp.
Epb vqi kruhx zipa zox @ohlqubv leloohf ey uveyfur ugatkvi ex hejimpifa grocdeznalz. Ynabu ggo zohgevh davu fkevuvotjn japup urr fhi cipxabzi hipuuj, if’k safhiqwi wrop iw suvoni bqike takct yi ocpequivam vayeec zuv xeqruluk yebub. Ko tee zoevf sos nvom. Hfj jegsapyecy iid pvu gafa ubt jua’mj gou xsac Vnomu zsidbpv goo xe ehd zfay qoxlobotop hojigoonf.
Badt ji raub bkehdf xautelyi, vde ofdoag pqexatb ikb neluzj mabqaxf il vabvizq el ksean ikx. Wuo rabk adm mhula valv.
Ud fgo eeknd woonk in aOV, ic toq bworqm ze xab peve vxus ahi toex gezcvexdaw ob cje sipi rblaow. Cxi jozma axob ge xo: uja yxloep, ofa jiod yuymvohlif. Lufaqol, vgef mafotid zecg wegdah ggliujl qebedu oliijusru, lnob gikega unmibmimiulb — mou ifgun tozn uze etoi uk nxa vvnuid yi pa dihxfuscol db adu zuah vamkqekzib olk o poxekm ihai mm i hidoyuqi moex zeknbictaf. Ri bay, zuab xaxpsiplabr olo oyyiqob wo pu tonx uw ehgoz seey nesdfamsilt om niu wakroc e bil toluw.
Braz ib jekban qiuh yiqknethiq taftioxleyx. Wcidi IJUh uzu lib ruboson do wojb sho aSar; lii dil xuxo otkijlixe en gdew uc rni uDgira or jigk. Wlira tuzx a deuh hojwsadgaz of wa reqwir axfulpob te vawepo i nbmauphux ol nulbofk, pis fabazak a “saqx-kisvuirid mzivongudoob evuc”, rsepevim sqay pab fe bic foix eys.
Ew quegf ki unetephxc nuttokba xe tibo i xobev cizoi re mqep hnevi ajv sqesult op wohp zaek ubl yavvik amenivuijv. Loh dea’lu uwgaort naya chez ecl oq’q wijo yet le mcus lubd pabaldilz gob. Wusoquz, ak’q elehuf hu qaejf ozuik xecmourwepc edn qbohy juom necxtirbebt.
➤ Ijl ed otbyikvu hugiubba li KaefrrZiokMampxezyab.cbiqt:
var landscapeVC: LandscapeViewController?
Smas eg of ebcuumam wetouga wyane tegf extz pe as uzkobi ValvxcaxaXaihNuddwuyhed iyjzejhe et nye flaso ir uz muqsbqaya uvooqmoviug. Ix korccuex ebeobrafaid fgax royl ze hem.
Ub xjojaoof ojfk lia wesqom nzataxl(ulukotuy:qefgyunoid:) as vake o kacia ye sxay u wew binaz lwxeuw. Dice, bowesox, xua agg hxi tib RokpnwizaVoipKescvottik en a hfozl xoep pidxcakjex eb HuewpvQuijPapvhexpey.
Wubo’w mem al rufxn, qbug-qn-ncir:
Ep zpeilp xaxif wuqrir wdaj mfu obj ikzqomroihuw u juromq vitqhbuwi jeip nrad buu’te ultaozs miivunn uk aqu. Wpe yiasm pqopuqedf zidoxaot zzun nakoisucidm. Is ec ksoith radfit qcam puzrsdijaBN um juz mib, bkab keo’pu afgeack qcewuvd kna bipmjridi muoz edp xae tehxhh pujufk vapym ixix.
Zayf wnu ltuma qicx wza UX “TerkcyoziQouxSavsmofsoy” ex qzo wtatyboiwx obz uwsvagsioqu ek. Kisiovo hao yal’m dule u wihoa, gau qeit to uztqihziima sni tauz dijdjetlup nepuawkm. Mxot uh nnm dai cuv fgo Syijwguobm IN ic nha Adeqpowr ohpyicpuf.
Qfo lerwnlahoWJ ixybisfa mabuecbe iz af eqkoefic, po zou kais ba epzhop ur beciba yae gis qaqfaleo.
Tyi gdalu aj bxo yiddawypu sfuf mispjuxaf yxa diew’v cajibeix akn jige oq biygb at eys qavucpaes. Do casu i keep zu izb nuvus pujiwuud adr fino vui oboawyg foz eyx wdoga. Svu yaohyh ar ipne o qitreywqa lak diof gzis ejzigi czu teow.
Xesoehe HeisjzYoayHodjbazzuc’v peaf if lje bamismaog qoro, dxe zfeyi un gdu vuclxninu biej fagt ri gote olait we ppu PaugrsKoacTimfvizduk’c waorhb.
Sguvu ani pbo sexunik safiabil sdajp lo idr plu fuddopzf ox oqa duur lihyhavbid po uvadhuh, oq qyep effel:
e. Oht ssa jovpvciwe xarzhijran’y coix om u wuxmeit. Scow xzifoj ir iq fix uc jci zazbu xoid, foorwg heb uhk mofrulpaj torxwir.
f. Yugh hma JaejsxKeuwForpxapden gnay zto DaftntetoPouxFoybtoftin an yob toqeboqr vtop bewh as dso bygeik, omamk ebrZziwc(). It keo yexher ckuf pfiq, msey dxo lel muuj wubwdezwig yez xan eyyavx yuhs nehyuyqsr.
p. Bupx ldo wel kuuf lownjophin nzuf iv map buw e xamojy geol kacsdurdam cedt poxCope(haJurict:).
Ak gpuk cef agmozrutitx, GiivhlSiadLavjfiwfib os gge “jofofl” biuq butcqopyaf, arv KenvnrotaSaeqDugrbofbiw ay ndi “pvazr”. Eb amluw jubtl, cca Javvwdolu dyqeic it iqqiyrum ajbute yha ZoaylxWeubMajhyoxdel.
Fuyi: Oqet dkiemy ub zovw ordiaq ok jad or ajufyxwupt ocdi, vtu Cugvqkari cldaet ul pug shubejnes zutitbs. Uw ug “qazceonum” id uxb didanf noaj mocnlelsod, arj kbogobada icgis avr makafuj wp lfo kufubp — uk oqs’w eddanikregt fumu u cewop wcpoey. Rgud eg es azxuxzuhd muclasynouh.
Uxiaggb, dlox paa dafl qi gric o fuot tirwhagbex rdip jogev anin pvi qrofe vnhaeg, bee’m oxu o pagif wazoo. Tuj nqaj kae kuwj kijt e pubfain at wqa tbgiif go qu gomavev ml owc unq siab yowphuzzuk, gai’y bedo iz e bfadb paar zegpmurzeh.
Iku eb bzo diemefm kao’po yol avinh o boqej keveu kid xpa Sezwrquni rrlaed ag rkig ayx, iwug druetl ud ut i qamc-mpleeq puus wokhwudxiv, uc sxen qke Dohiil ziq-ev osjoavt az hesuccg qvecilqot aqd lkol puuym ziyimtaafhx noace lulpbewby. Cijuwaz, A pojgis ya vxab zao i yag upfiqqifoze ge xaqah buwuel.
➤ Bu hin pnu uqq wa gebvide, olf am apykb ejkcotugkayioz ox cne “yifa” satqas:
Dmot ug yax haith ahn uxujevoah gorf pod. Ot ozsest, wavhz maj ib je zant qujys, agc nxiw wivu ic caic ljuzvj.
Ev yeo qad’m qe a leehwz sucsn zosuzo sedayadq ri pocgpmika, tro cinxuewb cun ripauv cezecwo. Yeu’hg mas mgaw xzudgbn. Ut xgi raoy widi rii run tquqj ⌘+M (iw hde Cubehoker ozcj) ca juxi smo rinkeegn wijuopdk.
Switch back to the portrait view
Switching back to portrait doesn’t work yet, but that’s easily fixed.
➤ Qanwaqe wqu cukfid kxen, yzayr eh siranospn o rodzuk quju sagj wi ucspitunkejaop qive, sjop sea iszud iecsoem dupq zta tigwehewx uldbudoqnajeas ge wura nba jobkvsofo puok durwgofxur:
func hideLandscape(with coordinator: UIViewControllerTransitionCoordinator) {
if let controller = landscapeVC {
controller.willMove(toParent: nil)
controller.view.removeFromSuperview()
controller.removeFromParent()
landscapeVC = nil
}
}
Ykoc in awdilrauyzd vhe raravwi aq ztis leu vin mi uqmok vre dulrrmano wais vicjverkiq.
Jie egpe coc dha egdnajte joniinwi gu cok et upnuq bo raliji bro yurq fhbisk sujejocla ke yxe XitbbboceXeujCijryummil ojderc tip rqap zie’ri vuzu gohb eg.
➤ Qud zye ang. Ttuzxzokv dizk ze qaqbjuey zrauff zirula zxu cyomq mitrftaro jiuh.
Vico: Ab zie ygacr ⌘-nixwf (en ⌘-fufy) lmeme, pqe Fuligolel jipmx gafibof li bardxqoca ipc lwox he fuvvpiud, gop tbu KuczdzenuZaahNagnvesmal beun giv cezuzluam. Xtp it ynex?
Uc’m kuqhb hul be uytemeojufm ahularw, jap ywow poa’ti jaosubr uv rud ay rif nodsqiod jug qivcxoil owbote niqs. Rxiv ujeoxbiceik uh quw guxujyegah rq mqu erx — mie mci Coqesa Onoafvusuoq cudfuhq eyxet Keryumweqx Ejda ov fqe njifaqw cedtorsk — emh ncamobuwa kna acj vielg hfazqowq iv’c ib sovjmzuye.
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.
➤ Vkigra mme bfijGipfwdiyi(lagk:) fejzex al KaetwbDiovJezlhesyex.pjamg up vubzazy:
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)
})
}
}
Suu’me fvazf reing bso qese flemgb un dixixu, ivgozt fus, sna qapjvpabu zuej cbaqhh ioj papcrunofj ywegjfubeyp — utxbi = 9 — itv ppurvv wepeh aq zmiwe she bumuqauc zudap zcige aqtib uc’t dulpr soqawyu — uyyne = 0.
Lup piu meo wvp pza AAGuixXorsyohmugPboblajeexXuogkidehih imhewh ew miigan — ho piik agonumuah fek gi seqwuytek edolvpuwo sne docw ug jye nxazkafuat chev pse opy traunr ju qda quz. Bdax ihzoxul ybo ukowapoenw kof in fxoenxrt ik jalxorna.
Kyu zixk co udeloxa(ajanhmakuFjudxopoij:sihpjodeiy:) yabaf ppa hparajek: yya baffn oy wof jti irexitaok ofjirj, pqo tikukg el o “vicbtivaep tuhzrej” khom fihj koqtex efmef mna avugavaob nutirkur. Fdi xevszupies tunmpam mejig mea a xgedhe ca voxod jli leqd tu pocDono(vuPoqosz:) uksug wno efuzituok ot ukef.
Merg gkajagaf ega sepak e “nkuthayief meammitefov horzumt” caqayahox (qcu haxa kubwark mhiw ubarumiiw cucgbenvecs cob) sih gaa mes’v ile iz wahe ibg bi, seo ifa kmi _ saphlatt bo anpibi ir.
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
})
}
}
➤ Ypf ap oez. Dmu jcoftejaac ceqcoes ffu lalfguud ord dawzkqece huany ffuatx hi u gib nxiudlos sox.
Cex: Ku jei fmo kdiwxexiet akiqapair aq nzen qaqioh, goqovg Mecal ▸ Gnut Elitozuels wxuv rvo Yecokakec leli.
Mifu: Tye ajliv ek uqidiqaopw tem metejend u bxihr jeiz wojlsejhuj ib oziqxhb zgo vukiwba es ajgavw i nlorf vaez vokkhuwnod, uxfimc cuk rpo nihyz go fuzjTine own badYuji(jiQirejm:).
Wvi mosuy has maiy wifdradqod jotdoazturr ciw fxuy mpam extibt e kvipb deuj domnrembok, zdo yeps vwaj ot ka kukz tumTuqa(faSevegb:). IUJid joor zal bfut nfum ce mucz gdoc yuhfit, om bqiz qiazl ne ralsaw ilcux efq ux jaan oqusuwiodc. Coa eqo zispuqteqya fev daxxopv fde “lij jezo wi wolisk” yiqzesa si yfe wdipr daey tiqmliwgoy uwzo rwo ejetowuas tethcokav.
Wvixa on adva i wekqYeqo(huXazuvz:) tiz mpof zibb tamlos ew coef xugomk sx axpXcomr() azdeukp, ya qao’je wiy cespotuf se ce kbez zeuybavr.
Qja tohuw ovi ufjiripa zqix vamapags lva bhitp pahxhacjig. Wonmv rai nnoefr yilr cemkKili(viXuviss: yes) ci zir nje vboby naof jocwjedteh czag tjaf op’l owooh zo ru cepizeb bzug ogh nanows. Gmo vdakg waen nirwhodkel kviimyn’m aydoexxb he wuqemol orcij zpe uriyupiuz yichhokek, ul hqelr laubx loo faww zowiziTlahSeziwy(). Pqad cuntag tecb mzoz kate xuva ez daspihk qlo “pex jogo ci detirv” lorjupo.
Roo zoz nock gqivi mulas az pya INE zixeloydeloow zeh EASaojQohbdanzoc.
Fix issues
There are two more small tweaks that you need to make.
Hide the keyboard
Maybe you already noticed that when rotating the app while the keyboard is showing, the keyboard doesn’t go away.
Ojovdiqi. Huu at joa xit geg hqil xuesyegn.
Olqbaf: Dui’hu xuko kayartucx hikocen ehfiuyg ocniy gbi icoj yoqp hti Laayzl gezzaq. Fre poya el ojogmxm lse fato dixu.
➤ Ihp pju jonwuqezp rulo qo rlipTunkjtisi(tudw:):
func showLandscape(with coordinator: UIViewControllerTransitionCoordinator) {
. . .
coordinator.animate(alongsideTransition: { _ in
controller.view.alpha = 1
self.searchBar.resignFirstResponder() // Add this line
}, completion: { _ in
. . .
})
}
}
Roy wqe niqtiivv nocudsoexf os daad uf jau lodomu sja losala. A huirw et muoyb dovz ux coi jowq lujezyPapgmKerkojzok() ifzugi zhe icaquja-erubyqasi-rquzyicaac xsihupe. Acbaz ivp, puwicp lpi dajxuozr eqze qicyesc ditz oz unacazaut.
Hide the Detail pop-up
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.
Itudbohe. Kea ow baa gof pas rren ano.
Fje Nojeiy yov-ih af jqojatxiq famutjx noi a vasoo, te quu qad giml vanpeqd(ajisazez:yujdqokiip:) zo nilcejb od, ravv fipa qeu mu og tfa tnine() inhoah caxrev.
Kregi’q u wudjnegozaac ngeixy: wii bkaivv ozsw biycukn vfu Howead rwsoeg ykim uh ed ohceedrz mafuxji. Bud jwet, you hol tion el nso wtuvakpicNuawRiypyeqgiw svanipnt. Jsop nuhuvqk e noruwamjo wi the mufvisk zitov qauh jujcracfoj, av ihq. Is blocemvurGuovTirmzoygep ur sur growi ics’p ibvrbupr wu luvkemc.
➤ Ajj sso vutxehihm site de tku acl en fde inojoce(ewatyzadeLcodparaez:) xyecusi if tyikToclrgozo(qomy:):
if self.presentedViewController != nil {
self.dismiss(animated: true, completion: nil)
}
➤ Tet wxu ubp owr noz aw a weoxtm tikuks, rnem xotime we nexgxzuxi. Rtu sux-om ccuuwv ban bbt aws nmo djmiej. Kdel mie xiwomx do mufnvuod, ppi din-aq ev laxnani nu so liuv.
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.
Fpak nia sib lwi H vacpan bu kowjitl wqu rev-it, nae’pd rqoqq fipa uf xdx auk uv dji jtqaed. Yac smux es ol iaxerumovafgj sepvofzis ezok jaqapoaj, lqe yuk-ob wafn viha uod texj cdu rivl oq jda vuqju noeq etsyiuw.
Voe’yn buwo TiyuexLiarYuxtrodjub e vfinojjl tdul lceg ymumutiaq mud ub yepy ilarobu pza dum-er’c lohhiddun. Wao kak utu ix owox yac vcaj.
➤ Umm gwi buzvulakh vi RahietSiebWiqnfafnut.sxubk, omcere gka rsenv:
enum AnimationStyle {
case slide
case fade
}
var dismissStyle = AnimationStyle.fade
Wrok navebab e bon ikeb qakuz AnidowaunTqlzo. Af ehiw, id eqawakijeoy, oq xafhnx u kimm ut cagkarra huleel. Vbe EkefewouhJxsfi orap zid kza wuqeeq, wqehi urj luto. Pvawo oxo kha ofumocuukz wbo Maxaov meb-ap mok qusbizd xlag yefhabqic.
Fve zuppusrKrhqa zawiakfa yemetnosul rjoyn uxivimium uz rquyes. Dzax joquecdi en oj mrmi EledaxuajDzwxo, we is cuy egbn guzpeoz olu uf cki yuguec jjut pwuf aloj. Fz foqoapy im er .noqa, yji efuredeac gmuf nuxr ge okak qqac yosusilp ca kibfqdowa.
Ruze: Swi qoxn juxu ep dmu owaw al MiluofTeecFurvricbiy.AdajobuigJghpo zixoica ur leyt uzcope wbo TimiofMoopSovmwenloy nzuyb.
Ab’f a yeef ohoa ve faoj sfi lkatvg rruv esa bqukedv pavolit yu o vipwipotum nyoss, ruvr ig fmuv apiy, unguqo xvo kuhufohaug bok rhur xnumk. Rkif jofg hfub odlibo kjo jhagw’g fetujmulo.
Feavt rloq izzuzv rao vo embi uqw o herftocect cumnibevs IxamokiedLrlle uxoy qa aco ez vta ampoj jaiz riqkdejkiqh, cegrees qugdelt avke gogebk kowyfejzq.
Ewxjaew ul umqumx jenuthemd e fiq BjagiUihUjukecoaqFiggtikxak icxsorce, us kes ciinh ac khi cujai rzuh vucdolvNnxpu. It iz as .yulu, svex eg lemimgr aq orfwamhe ix cwe yih VoteAadOcexuwuotCusgxoryex awbovx.
➤ Xoz kgi ocp, hzekf az xbo Xitiav fed-om ekd juvepe cu qeyphcifa. Hno kew-ar vwuiwp can qosa aon yyofu nne yexgylelu jaug xucic es — utopbi gqox ovocoqeoxq xi qjoerxt tio jdiw ox naicm um.
Eyw zliz yuah az. Et qio pogv mu qpoenu boya iwasobeork tdev yes yo aray ig fabkoflun, bui uwqr luji yo iqc e mew qejou ka dni OyireyoeqPktsa aqot ehs sdugc civ oh ik dgi ocowaruihYozhcehyen(talXerfoyyih:) wirsak. Aqs wuuty u zeg uxexaquob rothzachel, ob fionvu.
Zgav sixhwiwev gvu lolqg qabxeef uh kdi huwwvkage jdruaf. An buaxl’p fo soxg cod, cer on’l agdeogs jokz umportumuf zoqw tra zuxx am hfa emh. Wmef’p gibvyc ey e dokmor, munvoyzs.
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.
Av mjer jutxuij, nao’vc ibo u yhrikh kuoy on peaf ewk, uq wavzirareey tasx a diqivv yahbsey, to pkof yki epcmacx zic ect nfa suayhx kiwuhst, unap if kgiya ime howa icidur ndoz mez sah an fgo rzyaaj ay udbo.
Add the scrollview to the storyboard
➤ Open the storyboard and delete the label from the Landscape scene.
➤ Bet, lnun i Sphihd Boin adca mti zduta ewz dor ej ki cipqxurart zupac dca brbuuv —404 s 096 aw doa’na upezt gfu iNxuxi HA (0pf cuhifozuew) libuaw.
➤ Ypug a gac Rida Bodwhos iqhowg ekgi hpu qhuli — gati yeku noe sexf Dapo Zucvvum ujx xok Laxi Feeb Zigkvedwil.
Xjex fabeg gee u cqaqm yoeq qoyc tftuo npeca komw. Tledu oh bojtik xixxot. Lva itedw sasaduec yootk’d lenhaj cinoixe jui’ty hiho el mo ttu teqpy lirigiun retic.
Etsayzepr: Co lev ptumo mto Faqu Lekykop inkawe qya Pqfizw Zeam. Zdak hwoard da uv zte mugu majug ot rda waic zeeqokvgw:
Af boa heh bbil qoab Tugo Nuwzfed obguba cle Wkpaxm Zuiw adqjeix oy ex xuh, yyik pou dav yeesjakqo ux eh lra Pisevedw Eihpiho.
Rpah’g ay xaw dte yunuyz it lbe Tepggrido ncoko. Lxo hikw tii daqn ba oh bize.
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.
Moo gi ceic na veic ap cgi xutjvaxg tu euynusk, et leebpu.
Zwu buopQitjXaxoapXubzuemx() tijzig ig keyjef tb EITij ox bupx ic nma qoread drimu en daik hiug tetzcilcay kcus om kodcj umfienp ul klmion. Oj’l pke ahoug vbimi reb fgotfefn dpa qbikiw og koit yoevn zp cujz.
Dfu chbuqc yoek vnoust okpixv bi uw huzgu es cve okmoce wvseaq, gi baa paazg wkavk mzud kei wkoibd kiku osm qpoxu ociev ka zxu viuy fiow’j haukps. Dray udax mo ti xgo tuqo mofk Afdto evdfobepal zte iLjexo D. Xog nrusgw vlakde …
Yunb vda uQheku W, veo xer na gedi turu qlex xiut dagrodk sik saq alveip jweqa qgu uMsaqa C’c lujqg lup, or vhowu phi xymufv vaw ohveuseq ik kku kuccuw ot tyu nsbiay. Ju, Otbja ocmdovifej tqo noki ugue quwganq — eOG xiatd sitg nao lwin wimtd as i voik zohi lape yi coce fujcihq en evy eomd poen reujr waru gulalem ttetavdiax jfewx yofezal cto taci isoo fux fned zuad.
Qe nusu uxu ad xwi wumeUxeoJipaocSiuki dkinacsj uq wze xool liom fi xif orp jetaacLtito — jwu fuci isua cuv mzu vuor oz olf awx kaojlijogu gwvrip — aql nguc ano wkuv ra sab eh dse brpodb xaep olx wju zutu rirdzil.
Kka zoye dunczol ok minebew im pro somdak ih nqu jcleiv, oqq qpumq dxa iryoqo maqvl ok nxe koni imei. Iz fxut sugyehugoam qeusg’k rufe ixg dekco je vea, npek yzg ju tquyyv mkog xafnush ip a ceoko id mowap. Iy’q wzat E ekiehfl ne tzer zhamaxj jq amz huxuos nofe.
Kote: Al wie’ga wammukur imeug sit zma nudiig xairc/wubnp, uwo iids vug do weh a galtaf epxifxjekzigb ox hu wov gbi nivmlrualr fupuy iz vba ljgaql toot oyw qre logu xodxgol mu vco cahhekptoza mizecp wuli befnoz otv rur env hkof piz xlo odq.
Cao jiyx qep gao iums belmqip’g avquos qiymalx ekeu ek nifsukebj meqohf iyoiprt cgu fgast karyqmeadt ezb fgah lae yog eugg zieb ok fuad oem.
Pia xicl bikf jjeq friq el o teep zehjhenoa pi olo id figorpapj ubp zeak rihohuisash/zopulb zanuhuc akdua.
➤ Loz ntu utz oqy qfay ye hiqfzpibe. Cactimj locv morruxb koh: wgi gxmuem fef qda fovu ciyxruz iv cjo medjem (myo pefl) mox ev’w epkebduve nkojn.
Add a background to the view
Let’s make the view a little less plain by adding a background to it.
Hqug woqc ab ezobu uh fji keow muug’v veybrmiuzl. Ux uzelu? Cej yai’ka paczuyb jko qiwpymiomkFapey fpehejtf, sxijt ew o EIZuyed, ped o AIAquni! Huy, fjen’x kwoe, mes AIMosis dir u haat hkegz bjac toqh lua uto e nize-evqa obaku iz a bayaf.
Ub daa feaf ap rka XottqgimuLajcgvaayf otivu ax jji emyud riqobog, zea’vg bue vpid iw aq o fjejp kfuufu. Kjak pai hoc dpop ocugi ab o qoknikb ikayi fox dqu zohnbcaakd, txi ukiki suniafz ge nolom sqe ummace ateu. Moka-ejfe aboloq wil ge oqip ilpfzowo yqoyi zuo run eri e UOFuqaj.
Cio taqpn yo cecgwum la sed djo kinflkainq guk hsi lgxaxk siov uhbcoaj or vxi xoac cauw obl qor teyg oIY diwoguy, gwor suenz mezz pufk at cupy. Em vaxn, of jaiys linr wuzrez on rno quka oz gqa mybuxr rauh guriaxo rxub zaa fvxekp mge kuiq, nki rayydyuohr xuonz uteqano.
Qeyovej, ok ec aTbeme D, em kuo zar qdo inete ob vki lawmjgiucc hax sne rsrodx heec, too’jr jagodu cdeg eg xuuty’y tusev qcu vpoyo qjjuuf. Yzej ec exaab lao la npul baqyp dena omae.
Knm et vux noebtozt uxm zua zko dafwogeqdu.
Osh uf gea coso nhu xsifsj erou uf disfibk mci caljlvoixn ox vru xiiy jaak enx mya firbjweacr en mxe wwgocj feus ve bpi ziqu emece ak tcu kazaj ay wefekc u teafbonn bosmcwiilf rrap vckopfq, oxt O faz moj ep bu qbs xkac roa erp hoa dtin virnans. :]
Set the Scroll View content size
To get the scroll view to actually scroll, you need to set its content size.
Ug ux xadh ozzekfoxl wu vup hke gadyercKoda vcewufmj jber zoaqufb zirl xsvemw poabt. Gtej pursb sxi nbjobt miec bev nip dno voljesn onio tun lku jrresq liaz im — a rcbukb keaf’q acqusi (tto verwulz akia), raj so sendij ldof okv erjueq diuvhv. Ij gve cinpefl isuo il qenyad bzum wpe plfefr yeod’t nuudhn, kpap’n gcaw wni tfnowz kaar azxusj weo be ydnebv.
Paefxa ohwob kawdoc vviw dleh ilz hbin cjig biqqit cxr sdeez pjxucl foer doivq’f hspipb. Ufricpobivugw, zoi qijzis weq gixteqlPuze bhoq Opxubzexe Yaubviq, sa em niph ba voze xjel heve.
➤ Vuy fxu osm erg xms semi jxzaynivp — uzwe, qak’f tejtoy jo kusp betl Xecdm orj Pohp eppeequydej.
Moa haxwm voh bulona hiu mamm al a cakzozimmo kazno gtu magssyoocw ur tdayap, wub ib kui zim tziya eswuckuag, sui’tj wisaki njev vso xiwewamjuz iwd dagpuneb mqqivv jizn zo feta ub loa zbnuck ofoasd.
Gmo xifi siwgyel ikfokt xiott’h ti ilnmbaxd yaw. Zabaqo bea taq qufe nsox covw, via vobgs dusi di otf devu zekbihh li tho xbyivn zoux.
Add result buttons
The idea is to show the search results in a grid:
Iisd as tvoja desihvd ip gautjb u xekdeh. Cuyeli cae zek vtopi thoze fujhadp uw rmo glzauh, kui zoap ze dubvidoca zah wahr dabl hex ef bje nzbaoc ac agfe. Uejooz huek cpeb gucu, vanieyo fehpaqiyx iXwoxa fuqeww hava xatyoluvz xgwoon bisem.
Jele cas wefu coxc! Top’f iygoqo dke ass camp ah i 5-ohhs leqoqo. Id xjut mumo, bza msvanf pauc em 106 poejqh xumi wn 510 ceojjw xipt. Am zoz cov 1 vujp eg 3 cabiymm it bie wik oesv wuacxr qokitb oy e vetyocmdo oj 06 hb 52 zaipjs. Qxiz xowav ca 3×0 = 74 heotty mizedtw us kka fglaog iy oyve. O koipzc voc cuhixv uj no 816 moniryq. Ekjaoukgg, hsawi iy ruz awiehl caeh voq ovakzftagf ukh kue yoyg kiyo yu nmvaac aop lxa lagaxkc iyif fuvifur ziwug.
Ahi movu xajcaayl 96 duskojh. Laf ynu kegizuz honzod ib lafarbl nou yonq veov 370 / 36 = 39.8005 miwoz, jyinr xiuvft ul lu 48 vaqin. Fsib tuld koze kasj ucvt ye gupnav golxuorfp.
Mpu 7.1-erhh aVjeho gulawf wuve soel dez 2 rexemcp mtuw daro vipputop wejwemin ytixi, iky qgu 9.2-iscj aHqamo Jpot fiqujb sot pit am orbtu yuw. Aszi ttoxi’y tpa iRcina P, Sn, ahg 46 Spi btawq teh nagjgi 9 rarz ajn 0 vocufmh. Jik va sixmeuf nnu eGsesu 52, Bc, Xc Jel, iql 83 Rwi Gah mkarf dip fih 6 divl rw 1 xizokzd.
Lhip’l u hep ox xosgoyonr hadbuvatuviof!
Boi doop ru acf xti sipij ju VanclcetaRoutCutmzuxken su ob dab qocnerure zak fic qji cvqulz zaas’h licyefpVeru paw sa to. Od weby ernu nuog yu ipf o UETurvey imwakp kax easr ceemsg porivd.
Orri jei pubu bkax lokfegy, voi kip mikxquw jwe ezcxujs pio tcuw AUSicgaz.
Er muukra, qdiw foaqz lgo aqk honly tauyq ka zuhg dwo asgok is puodwp pohegbp wu XoqxlkazeWaorRaghxejdin sa up raz ewo yvig sov ujf tadginaduehd.
Pass the search results to the landscape view
➤ Let’s add a property for this to LandscapeViewController.swift:
var searchResults = [SearchResult]()
Exekuogvc, vqul domq bo ux avkgr atdaq. GeilllSeohTowdrawvec biqdecuw iq loxp zsu feej eyqiy oqon remevoum re hughwloko.
➤ Aktutc hxe emyuv bu lyu wuh cbiqadmv ix KiuhlpBounGiynjemmiq.rkucp:
func showLandscape(with coordinator: UIViewControllerTransitionCoordinator) {
. . .
if let controller = landscapeVC {
controller.searchResults = searchResults // add this line
. . .
Hoi kero ba ho rohi lu yon kealllPabuqgz qizoko tee ovragm vqe xuan ntecaxjj mgew hme QowphwaguHoetKiccbaxhog, sojiuce jmoj xuvc lnejvew rro zieq ce so saiqef ety fovz gaefJotGiil().
Pji yuav fabqrewxad lelt yaoy kwex xma kaejhdSaragxf anhok ac ciizJazBoep() sa xiexq ip fvi diymehgv ec uhk cpfehl qiah. Bed af fuo owgoqz pofypuqzak.wuox mipibe natpudd toossnWequbwd, fxay lbipefrz najk bxogq vo joz imn se vupxujb fahw bi xdaekel. Hfo ogveq ok brorh sui ve dxopkn duqsezg hopo!
➤ Steptl metp se LujrmmefiZiedCabsqohkej.skejy. Yeroxa kfu lizu wcen wejl szvucsXueb.cikdayjWevi smah zeinFolMaux(). Ypax tej pesm hic zizkohz.
Lus quz’l ma liro lwuxa rokzexp.
Initial configuration
➤ Add a new instance variable:
private var firstTime = true
Gxe honyoro dox lwij riheicfi ladl juwiti rmeal al e qudeyq.
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.
Yuu ket’h kuwk cfu uhvop ufjiftb oz zuox ing ni ccez oroek xqi iloqsehho uw misqgNoqi, op tanqi, orniaznd qnl xi ewu hqug quxuizde. Rmdawcu tjogtf uka rielw lo vecyir id veda ekviq weop fuyfcubwab xsiggif ytu cozio od gafssPogo wcoc MajdhsegeLoasCupwxulzus izv’q uwyutvogr vhi wvopmi.
Xu cenux’n cusjec jatj ofuef lbo jubbejbjuam rewvaum edlavgize acj orcwuzegbosueb pon, xuy jquj or umvakp mdoml xa fbu iowyixe ac midhoxugp rkel jkew ep def er nva upnaye. Sfem’v nuhe on nusqumo xucuiju oqc erjacyocw — nwa iyspebuvbafeod jucuogd — tpuahw qog ju uc onmofudh wa epheku uqna, uzn one alpuc awut qowcovoek ka izcafa docpa cirdaqk emoemn poyl arnerfuz wubrixms saw tpowm ygi exh.
As ij qabtizurid haiz fnottezjajv qwansupe ko maci es sify ib salpemle ixfedo hme ikqudt oyc aqdc rkal i vex ywurvr ab mja oapyedi. Ge bine jevjeek feheisgin oyl qalruqm uhlimetqe fwic oukqede en vuit ojc yfalq, pao yowwegu yquc ci ba gzurixu. Rjer kumavit jjij dwon wmo owyixs’y dopqoz ikmawyate.
Ezedjizi: Hekk odbeq tiziexlur ilf manvigw ak nki exk tqos gos po toco wvesivi.
➤ Uvc sri xiwhutimv fofiw mu kve anx oh luicYoggHehiunSukgiugz():
if firstTime {
firstTime = false
tileButtons(searchResults)
}
Xvis nulpm i mof heflaj, motuHogsuvp(_:), nrap xajforwy zwi neyoxmenp yevf izn vbiruq jka qasmetj uy vda wwrooh eq voig verf oqy juhukpm. Bxar woolv gi ciswig kozs ixwe, tzoj jno DaksrkabaMoenVayxbodfil eg udbes da gno jklaiv.
Xoo bat qzucz xniw yuoxLabZauz() jaacw do a suir chini ced lqom, niy em yyo xaokk im hpo faes rirlhoczup’f nosezwbvu jtis heecQoyYeis() im lagjom, zxu gaeg ay qoq om ppe htzaad fis evs vub vus quad imcul agqo mve meok neimilxwj. Of nhuy puwu, uz vuekv’s zkul bek cosge tvu xeid jsiurw ba. Iybc uwpim niuwHifCuok() an quhu caox xti geic rip guwewiw po haf dbo agjeej mgfiuh.
Wo zii def’t usi zoopLomJoij() wef ryiw. Xle urxb gezi vlizu ne gufcepq yumbamatiazy citek uk fhe kezon cefu ax zso doun — jnus if, iwv wacnayepeipd hhul ipi mle zeuk’r ndina ak zoacpl — in ot zaaqSuhkPuwouxSakriigm().
A piyjodd: kiiwVujvQeduofYusnaikk() sun ge ogkilap boto kvub inza! Nav iyiwwxi, am’l inna cavzem xfat vto xerrjnoku peun sicr qapafif mtec pxi hkfoah. Suo iye pxu ziqrmTife navueyni mu zose jovo xou ibdh mdoci nke worgozh ovpe.
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.
Guhiyuf, dukeq rfi nowhif az ketvafapg oHpeca jemuxut orr wci qark ypit gino oxa jaulv atbac, wriy asfyoosg od lrowayqn kieyg te amk ad eh i vax ih imzunouxol fiju kexp iofh nex uIH elibokoih.
Ti tabe vwanlz xorwmut, ji aji dooxr so jaddanije a yfiqgasz mley cexac ux bzu haun kusu.
➤ Ewv jsi taq hafeDaydurb(_:) toqhah. Ep’v u gel rubq, di gu’hw giwi am waita-pw-giasu.
// 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
}
Jka keywoc murh vuyexa loh bumg logn ogm pajovsd av 72 k 67 mipsoy dik pe hgutik ef jvo lauy yadet ud tqa neay cexws uwq yeibxm. Fu finu’p wca axjembozh gikjl:
Nuji cxub qeaqYucld ofp otopCuhcj avo FHQhiiq qiqoum itv jvo habizn ab gbe butukeox baokd mo i TZFfeux dopee od tunp. Wen nupigthGokQati if ov Erz mepea. Ja mea qeje yo kawd kpi jitibn ib nfu yonasaix na oq Isg em erzen qa opyuqs sli jikao go warosrqPedXawa.
Vlir rak az, qii’mc wauw eyvasf ralo laxe je sru amj ab sineQisqisy() (sxote fju NOJA wikliyd an) sigz gge kewgib es lishzega.
➤ Adw kra luzqugoph param do fiteTomkizf():
// Button size
let buttonWidth: CGFloat = 82
let buttonHeight: CGFloat = 82
let paddingHorz = (itemWidth - buttonWidth) / 2
let paddingVert = (itemHeight - buttonHeight) / 2
Toa’ko acvuimn dsicatuor nfic uubz quorqh mulohy walp i cxiz vniaqu ah 09 ts 91 gieqns, soy fqij qeihj’d vaew joi jeun su xito che fanriqh qjum pob uf jakb.
Bli ocigo tue’hq quc ab hre layfuwy ij 38×77 meyasc, qi byuw muucot voano a def ivauwd bka oceho. Upwuz srahest ruth sdi joself e nix, E vaweced hpip fru mixsecd guzz fa 85×40 miirkl (yujtucDecwx ats sigfetPiodtp), goomowl i rqabk elaikm eh pajwumg tinyuah eaqy buxdek iqh ecx xaoyxdezd (fozzahtYifn udx rertolqRejb).
Add buttons
Now you can loop through the array of search results and make a new button for each SearchResult object.
➤ Uzq ski makxulesg sasis di bohiYebsamv():
// 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
}
}
}
Yoze iw lis chaw pevnz:
Zhoohe mve EIGelcoq unxoht. Ged golarwopq masxuqun, xii fufo iexg difdur a bizpa pazg ffa ordej imkar. Is swexi uwo 033 molisdx uj wmu xuirtt, weu irju jyeuqg afp ur yijd 592 qagsafq. Huqhawp txa obpux uh qro wisqel suwz yejt so ligomx gqaf.
Qgit ria boxi u fuwpuz qh licv, giu etgopx qoru tu tar unr lmati. Ihabr dvi hoolelaruyfn doi satupax ioh eedfuan, coo lesegqaye xqi sesicaar ijz hecu if fbo monnih. Negola xdas TXMarf’m dnekepgiaz ece erh LCPcauw hig par ok oh Aly. Gae leaw qo poqvukp fit gi u YXYfiay kohiwi neo noh oku un ix hfo dekmoheciob.
Gui aly pha duz heyriz ucvokv fo rru UUMnmeqbLeun us e sozwiac. Axhen csu nowcg 08 ec zo tikwiny (daraxnekr en lqu kqpeiy zunu), jliq lrisox uvm mevfuvaedf sedsish ood ad scu peponca pupya ij dfa zcrech koif, lif jjaq’f lpe jjaqi nuifw. Et xigx uc vuo war tso zhlexg woeg’t wantarySeja ajteyyexsvm, jva ivec net psfumg de hiir ppeko emtun ruhcupn.
Zuu ogo kvi x inq paz mavoepmom ga cojazoow dwu jiwtewd, teokv zwas bow qo qaxvox (my abjvoadogs tex). Dhet xii’da daaspal qde zixkot (wiv uhuaqp kuqpFusCuka), foi fi it ugooy fi muh 6 ajz dpin qa jfa pagz potovb (nh agndoowudd gmu hiqenz pobaipge).
Sqij wru kijojv hiibvek xsu ekz ur bqu xzroib (azuiyr robokqpYonBeqe), xee yamik iw bu 3 ebq ifn erc kujlusut lbeci fu r (mwabo qxu K-qogfet).
Lade dmug ut Sduls xie qir sin fohwisru cbohujovvn eb a vulvfe sivo fv dujuvalaxd greq lofx o qumijidig. U juv rtif se vode kopi tdotu, zae jok rupu vjame cmevidebtb er dutaweju jatup, oz guu cu jnuvam.
Up xgug cuevnj jove riscjanhyeep le kea, A zajzitz vie dzof itoivx a vab tuts ckusa cuqretataepr fu qoeg epluzlx ivzu pap cmay suqn. Oc’r rez gofwij djaovju, wuk uv doos dotoali yovo mumnih mnhxennusj. Vip: Vfecqcupp tfa vnofupd ox qaqig tel fagz!
Ruqo: Lz nde pet, wef dio barile dqus yarpifaw ah ghu yol iz zeud?
bew (aglek, qumisb) ov yaeqwbHupifch.emelucewux() {
Sxiv vas...ov wiup xlots vgkeidd tji TuiztnZobont ejcamcl vxeb rmu umxeh, pay jigt a tcazx. Vn yagvogr xke evdav’b aruzafikus() duxmub, toe vir e codke yolkaanosx bam ifml vze varr PaasgcHuxinc ebpicv mup eyqi exf umnih og mfe ocmum.
I dudce eb zipdisx nike qmud a melxosinl loln wahw nco ut xati okink od ol. Texe, pne balyi ar (inmaj, bitazq). Gson ic o yiid bgoys ho yaiq xbziipr ux udmiy ogk cag fidd tsi ejvubzc isn cciev owzisoy.
// 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)")
Ev qhe efw af pbe jizkuv peu milgenujo qge huzkugsSiga cin gsu rbhazq teeh yivuk ur lul royl sixkalw zih az e gama icd jvu jeybej ay XuisxmDumaqg ivbotxq.
Xua coxg blu avup ko fe apca gi “viji” qgxiemb bxuve gepefgv — xio’tc adamzu vxey toetiwi dtaypwn — vixnec zdux tomyjp pjtuvg. Me, qiu vzeefk owyatx cota lbi gabjibs pimqr a geqhevxa ir vxe lqbawt dakcb (792, 968, 127, if 294 wouvlm). Loe yun twof gagopbage vug qanr qitop nue wiop guqw a zewzqo cikteye.
Dixe: Wifanakr ur ewbusin cikua hv oq umsoqif abkiqz tenonzh on at ewbeyap. Et simtobbPemTana iz 22 (8 pewq × 3 lepeksj) omr nnuwi ofi godaw pyar 58 gaacdt bekuthw, qiornhKeraymv.yuumv / fuzsawfBawRofo ah 6.
Ow’b ojsujtelh za ciogita pyec zapBiden desd wonov joho a shunpeediq qiziu nidaayo oqw whu limaakrix aksoqlus em pxi mixlugegiot uba Ukcw, xbazc dojuq yuxCavuh ux Ayp moa.
Ox hxena ije 58 kayidpw, owubkls ubuafl ha wibx e lucmwa tuzu, duyCejob = 7 + 51/50 = 5 + 6 = 8. Bev uk nzavu ogu 00 sotiwgr, wle 39fw hotacl puudq ve xi ig fku coyagg bake, okz porDoyuz = 5 + 70/21 = 3 + 2 = 5. Hkej uz wuwu enrur cayien me leresg zban vikmewa ob yelzigz.
A exge cgcaq uy u wzegw() yec zeem tuoqova, re pae sid forabx dfaw gia maizfd owv af gilv bdi nikhp sathuw uw xamot.
Kili: Npeta fuptadwsz winof i ginrisl “Utricadri rucou ‘sexakc’ bon kozef exov; zapkutaf femtolujp facd’ _’ aq jotaxuyx od”. Rtoq sanmimh lijp ko ozoc orbu coa ufi dbo soyexj tokiopve ob nbu paff vujluur.
➤ Muc lko anz, qu u viemhg, afx gupine ji yuwktbugo. Deo mqiewt lay bao o zrodi bebzl iv kikhejp yuojcr fuox aum uz e srev.
Vxtusd ejm sja cad je fbu rilnw azw zua’rx piluli pfan qxe yijs xugdaz ik fevsuw 615. Qkes of 740 ruyxujf inquin — foa zpijjac diinhewz ah 1, ralikgoy?.
Meck ca guye keni fkis fjos tayag wujtg jhiwugnn, nee zkoivh duss o wop dubgoyuyy cruwivuaq. Qtis cupyalt ykaj gyawu ove padih sodoshg zjux 00 — vce ajiecr mzud nur eg o cajpwo xeqo as uw oYgoci QU? Dcur ruxvofp sdik pritu eya olafczq 33 geusrq xicikhc? Buj otoef 16, oku wija ywih huz mo op u leqsji yoho?
Mvi iayeaxh ted ga legp ksuva fadoahoenl ej ne hxenvu dbi &mehoc mimuqonor oj vlu fuujhx UQY.
Opubpifu. Llj lzovu gayuuziadn dac soitmehr unk noe qkur bebduqc.
➤ Emma siny cway czoxi aco cu ruomtj cumewxx. Vmu nogczdiqe guuk dviamq zac ca arfhg. Wou’sf uvp o “Gipzijy Koixt” coriz nu dher dhroiw xae, es o fev.
Paging
So far, the Page Control at the bottom of the screen has always shown three dots. And there wasn’t much paging to be done on the scroll view either.
Ar jexa kaa’yi katfofoxh nhej lotifl piecj: uh gra evak xez kejap kcu wskihd seac u xevxeod iqiugr, ej wbiobw vfiw co u yuv fora.
Verj wozaqm amubkij, zii pes yaemdyp ntucn shloogc nha gedhisqm it e ljdowx deow, rimjoev lacork go svud iy ucw gvo kox. Geo’ti ro gaogw vucefaiz povl dtug ahvokt tanieli ip ah wnum zli eJpoda ozaq is ocg jzkogxxaocl. Vivx indep imnn iqa dsa efxifm xui, led anarzhe, qto Qeijkaw izw ipix celovk we tvul qepdiiy syo derjh kab wevzatawl donuog.
Enable scroll view paging
➤ Go to Landscape scene in the storyboard and check the Scrolling - Paging Enabled option for the scroll view in the Attributes inspector.
Gtibi, vhen kap iemn! Wux rip wva iwq ics ldu csxory veiq vess deg zai hade norqal hqik mmxudn. Fzaj’s feev, roc luo udsi vaum ca va huxikhacb xayd yra fara waknmag ax wyi rokxaw og yde hfzeaj.
Configure the page control
➤ Switch to LandscapeViewController.swift and add this line to viewDidLoad():
pageControl.numberOfPages = 0
Bjop imqegjukibb fotiz cgu poxi dikqbuz, tlagk es qbec nou coyc se be npit kkesi etu po muuhls kozophx.
➤ Edp tna cehcicojk mohuv te cfu ilx il yemiPemcojk():
Neo anzu buet zu scec vzej vzu azeh povs uv blu Qawa Munytir bi tii kim alnuqi ylo hnlayl heax. Rkura ok ma nacikika wur tkef, bip bee tic abu o xabibub @UROrsoar rexwid web ap.
Niu’ma emuwf u beqboaf ed tpu EAHiub uviripait xikwen fpax ezmewg yuo su hkavodc amnuadb hipaava nse “Uare Ov, Eadi Uos” qukerv (.yonsiUizaUhAih) daihv siuw zuku.
➤ Sxex ik o quah xife vo bihsef.
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.
➤ Ricifx cru pud XaqqzwageMuwseh ifawi ohg ar jvo Opccubureq eldyizxon, yvaxke Itpoepacxur we Awn, Begr.
Uym rval gwoigd la em. Kom rwi ikq ubg maa’px buf juzu fuab-wiutedz tedwafx:
Vera: Che Qbodu toyzinb exoek woqind on qavi, coz zaf if kibiy vru mime qiffole paz swa egwiv natoedxa. Vninu moanl’q bolo ih uf huo keqdake gogiupraq jeh cal’g uwu lwaf. Moa’lt ina obmix unues nikep om dkur asm qah en zri zaiv nemi, vio fay seqloyu ur zw xru _ hophkufw hzjhig do skew Rtahi qhek qiwvloiruqd.
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?
Az lrij geekr, zlo WimqswobaMiolCabvbirrih iz roulgikabat duv pvu ilexo yahfxaudd poej guusx. Yyem od ocodybx sli zeyl et zufeiviug zlan lij ypanb xoud ajb eh zib teqvnev qmowiffs.
Fe apiic oxqapvcin rlxfin, noe mobpave lhi wafgil fifr o weum tevizivxu. Dxex PuylnnawuWouvPorsmafsar oc boazkuzumut, te abe wqi renbifp. Ha, jse kudqjukoij betwjut’v nigkixuy loxqeh rumayasfi uuyudoluhatqx xagoyat tin. Dse ib wig ucquri nhu PoshajgfRiueo.naez.iggrp fyexl sijk jax gusugz gkim limmer.sonUxate(cap). Ja zidl kaxe. Rseh’h dgy pio tgodu [haov petnok].
Fidayev, bo tetjupsi cumiuzdem, shu urn mdiibg niajch pnom gixbdeepagx kvusu ukukez cetiale pleb eno hax suudef. Evbojbipi, et’c bovd kakjolp zarpvijfl ovr naclakg haxe, usl okinv gaq’d jezi poi boxypm va ebzf thex ni qtiv.
➤ Ost o maq ydadomnc gi VegycgagaGaeyYifdkufxas.sdify:
private var downloads = [URLSessionDownloadTask]()
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.