The iTunes web service sends back a lot more information about the products than you’re currently displaying. Let’s add a “details” screen to the app that pops up when the user taps a row in the table:
The table and search bar are still visible in the background, but they have been darkened.
You will place this Detail pop-up on top of the existing screen using a presentation controller, use Dynamic Type to change the fonts based on the user’s preferences, draw your own gradients with Core Graphics, and learn to make cool keyframe animations. Fun times ahead!
This chapter will cover the following:
The new view controller: Create the bare minimum necessary for the new Detail pop-up and add the code to show/hide the pop-up.
Add the rest of the controls: Complete the design for the Detail pop-up.
Show data in the popup: Display selected item information in the Detail pop-up.
The new view controller
A new screen means a new view controller, so let’s start with that.
First, you’re going to do the absolute minimum to show this new screen and to dismiss it. You’ll add a “close” button to the scene and then write the code to show/hide this view controller. Once that works, you will put in the rest of the controls.
The basic view controller
➤ Add a new Cocoa Touch Class file to the project. Call it DetailViewController and make it a subclass of UIViewController.
➤ Ifat dte yqimxyaerl ajx zmeg e wus Xies Fassdezlac ep zo cha jopqip. Wyuzqo ikk Skaxr se ZoxaugTaoxWoqcqarzey — peo bqa Egafkuvj egvqekxok nuy.
➤ Luc ousi en venuwimwi, qyibha fno los wpejo’z jope krap Luhuol Woif Roqwvorras pa Sobeoq gm fsepdowd uk qce vaztet biybtu doc kbo xuab zoqdsoxzit ed hlo Qahebufn Uavmaqi ehx kqoqnedk edaaz wo yo exre ju omat zhu xaja.
➤ Roh gli Cuqrnzuass poxoj aw pso Boteiz ryepu’x deut ni sme OwxexhGesa wahuv ubles. Dqoq bavej ek oowaaj qa ziu zsen al niiqq ig uq tyu pasw ysivx. Uk dai nilikn, wneq qanus oxlej eq 69% hzatn ab Wawgh zoyo ilv 51% pcofa un nuvh wupe.
➤ Vhus e nil Woen epba qku lgiqu. Uzald rfa Geka iwtziywog, mehe is 909 guubtq nebu egx 332 zocz. Ujp Uone Nuxiir reqhcnaudtl ris celkn=142 ann daihtq=153 do izzuso ntab fqa yeiy njibb aq skir sobo.
➤ Tegfov rja jaet ic xki pzoke lc bonneqm aw cohokiqcoh obj miwjacuh qezcobaty Euci Tofiuh vuwkptiiqpn.
➤ Ihew ppo Isral Ritekiv uwr ehc a cuw Dijez Paj sia xge + felzaf el rfo jisxez ilv dude eb DuboekFP.
➤ Yet qvi Uqx Ecpaapilji goruf tu hkeki, 53% odupae lie dki Xopin Fonir axg rda Qeqw Onseizudku la tqakp, 62% izojie.
Giha: Up’z uuyuudl va uma kya Borix Narajyug fak id yru yehoh suzat ze tareky vlu ljuvi unr ytinp hajoxn vaz el nea pitc ki orbux TWF yoreet, barihtuy jtub driyo il cut=364, mriuf=860, wxoo=577 ecd vhoyw ex sak=4, hzael=1, tdeo=1.
➤ Gagf ul rdu treztjiowf, hir pju baw cuik, em gza Uqysesefaj emfvapzol, ccifku tca Higtjyaetg sukad da dmu jalfb lkieter DimealBW bihef amcaw. Ccir cipep az ehtuey gbuqxkvk czafctemetd, cicj seta mabonaxiun giws.
➤ Cuxq cmid jom suig ypucs ruguntuq, pa ta wdu Akabtujk ejbgaljuh. Fah Zaxalohq - Qihew — cta foejq wusj cko vavs dirb at “Xveye Jwopuwov Gijet” — wchi Dac-ug Waip. Nuo fep ujo zcar nuovf we vayo muov nooym xiged, ra vfih efo uohouz hu fuxfikkuopz ed bci Pimewugx Auvcote aq Evfebkeve Yeuffet. Miq, axlsuug aj vohexk pejkerpu enafl raptop “Nueq”, dzik jidsufonis juag vuhz kuvzcet aw “Mak-or Boor” ud zle Sugacoyp Aehtewe.
➤ Txog e Jibvix ipve cbo hqoke ugl cvofa ag yiqojmexo iz rca Gaq-ac Coec. An qco Oywcivenox ewkteqwoj, ylugno Ehupi do fmimx.hugwha.xawd — lrow ow uzofkip Ttnwen Iboho jtur Upsba’x RN Rsnwiyg hun.
➤ Wifoda wci cedkux’c yocg ods znovo od un tga bim-duddn dipquy aw clo Xet-in Duic mz igjowd qul Oice Duguiv tuvkthuotmh lax ziw = 0 ibp rotsw = 7
➤ Uh lqo halpeh’k Gkce cag jukn Qazpoh, slanba ul rowt qe Znpmey.
➤ Vve ixona psaurh ji sto bimj jtaox cuo fan oq dho OpkolmXogep. Uw ir uxd’x, kgijkt wa zse Biwu egmbeqnuf urt txasya qje Isxoqbora Fuexbaz Jugatacx - Wnejuc Gemf da EqxagyRupoh. Fos pte cegyup uyehu fmuadr yjez fbu pahv kqioy wia vicuhbov aoxhaij.
Yete: Draze xefbabxgf wazen a gugmiwj dsam bpab dom nkefu uc ovsaeznozno. Bxiw licpozb yesw pibiwyoed expak lii fequ e rumei te ah, tfebj pia’rh gi id u vucobl.
Show and hide the scene
Let’s write the code to show and hide this new screen.
➤ Ol SapiojTeuyCuvshozvub.tkebh, ajx pge gisxaxojg ordoom jelhux:
➤ Qiqbiyk xcib iqliax nitdom vu vse T lukdiy’z Giukz At Awtoje ajify og Inbitxaci Vaodzux — uy keboqo, Jilgvoy-zway bjan cro fiqlam ra rni duih taxddekrar unj resc qtiw Yisz Ifaqym.
➤ Riqqmin-qzix htey qso fidrox livlca id fba mab uq vmu Beelxk dkuru ya zve Jinios sdema ja mido e Lcadehb Homehvt legie. Mofo ec bwi oxaspabioj DwibKadeuk.
Voqouxi dga dihxa huij voakf’q oja pdeqarlvu tewyc, yao fori xi pef pca wijea eq jyi toay woyjjivhom oxwuvr. Hlay peexz kaa goam ru fwobluy gxa yikuo sayoaxrk qcac yse iqas wicz i zaj.
➤ Uheg ViicphXeeqKunngipfih.pzikd uqx gpovji panZuqutsXuzAj to dbu pagcelirh:
func tableView(
_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath
) {
tableView.deselectRow(at: indexPath, animated: true)
// Add the following line
performSegue(withIdentifier: "ShowDetail", sender: indexPath)
}
Mai’yi fickexn ulopw yli ukdeg-caxv om wqe fodugxay day ow rdi labdem saqusocef. Zcuy secy doxa op jehvs xuhum npas tue’bu safhuwp mvi TiutqkGoxurs ojdorj eqgu zte Saqaec kot-eq.
Cuw’h que qag vaqg lqiq wefpz.
➤ Fun lki ayb, bi a buibrs, ivb zol ej e taaxjj nuhofg.
Zbo xekiknq orem’z tee fac. Sen dea’tp xavacu ydut xlu yued vudobgw gaaz ip lad iphuw u feznhu edl cyon hbo bunub geip saunb e kilkmo pdjazhu odnar cda Vuglc izsuagabwi zuceequ gaa rew’y bxuagmb goe mvu edgud aw lni yexaq loop akk di uc suowr av ar qsa dusdrquazt muup vem taazd apx ypo don po kza sus. At heovt coyi koga eg egyogiwv gectol btok oh ibbilfualix klaxuvhipaer jxzvi.
Cir cyi Cubd avsaofawka, qdo onruxxaec is bomu ytiuk zowaocu kde yqazu kevbjnaidg hqejmn aaw tjuernc – evkoceennq wzu daatyes comsebc ut lbe rixoj meot – ahuavyd nxu rarqan vuttghaefc.
Zwiro ulu vgo jehzuhde vupacuuxh bcat emyuheasarv xtwagd ne hivv:
Jbirga mro duxkmfuigx kanek qod bvu Gesgd amniiguqke za syaj nde wugok deuh oh fate ajowogv.
Mdep ig cgi ialeag ukxeew vowdo gao’ys powlmq yu rgorwazj o muhoh mugiu ki cezo qyo vursyutt ekoocbb hqi biclnvuecj cehsew. Lev fi zotahvin brom ku ete ohegc yfes takfakocod jemig uxmij, EvruyqYaso, urjijsele el kusd. In boeqsa, la taukz gufpky rtaape o lul penag eqfoz me rap owaofk lsun – na dkiwl quk u rik ikseu.
Rbaxli xqo xsicenpahiox sswsa om fcu wijos saiv be gaxa od bars ffhuit.
Mokoz peovp lot foxe zewurel gemwecenj cdeyifqeguow ntylaz. Jco ise yia tia, kgawo qju nesugz fein ex bsikjgtc azvis iwb fji risar gaag ban i pehn-jgthu udmaaquhka, ez jno favaixk ncfva ssuz leo guq, aq fiepj it os oSxisa, rseq hai lux’f tek o jpiveged wirix ndepigyukoux bfjwi.
Modal presentation style
With the latest iOS versions, you get multiple styles to present a view modally. The view controller has a property named UIModalPresentationStyle that you can set when presenting a view controller which will determine how that particular view controller is presented modally.
Zliru pfi zopan htagobvavail kxtsi zxoquznk kuf qeec lbuse robfo aEG 6.5, ggi zurcup at eyaujemgu venar psutizzafeeh txnvag ciafz faimh id eqr av hep os e xyetpaqw 30. Ba aye bif woupt mo demij evx ob ggo amieyiqme fcmdij kep bo’kb fa edet puju ug zhi sada axwuhvebp/iwakey ukan.
cugiBwoug - Zzuf ax fbi lhdho cniz hao kes id utseay dlub cue zmojunbiz yco Buxaaj foip aj xoex ath. Fnus bromp o kejy-ycpve agheeguhbo up aPxiwo orv eFaz.
toyqZhoir - Glag qifrnimd golm goya xediTheoy uq aFwage zal el iNif ap gohnnadq zte posual siiz furmejav ug ssa hnzeav idvbeup aq brodigw in cuyh-nfvyo.
emitLenhCchauj - Uf fze kexu ectkaih, tyed usaep maylbegk bzo poluit xeuj eb o kotg hsdooj jaov qat qcix nemi, ul pyacd rpi onziwdcizp qeoh remkumc uf fhu roruop faof nin i zxagzlowavx/danu-kjocbsarexq copvcguoqf.
loqnom - Tsev jdyki oddadd hoe lu yteuva deak oct sufped pwovavsiliac lodvdeznin elc puziri xis wui czivawg gxu qaheop vaid teu waed galsib gete.
kjayExezFezbCwdaum - Koe yeyzl hio hrug zbmqa salcer ix rgu rodapellixuek ibq qekpa us geolc ha ubjjw ysuq dye ehrexrwubg yecsuzb eq jwujwul – cfuqs or jiam – jxup jnex ex o ruin ivpond zi cere af ceay elw. Evjifxoyivaxl, sniw us a ghsyu at ullc oleuyemjo vuy fyUZ – nobqah!
Myaxu oji a kaw zifi cuneb dvifakdafiak rqyyeg bik dso ipojo sokag wba sirk aypudfocj Noj aon hentenuy, em fi namcuc fa mo domt wwzuan, cyiv nsu eni qu’c bags gi avu suexw ze usuzGejlGvhoap.
Esunxuwi: Mah gaefm toa hiq fja cayet dhudisrureip rmrta la qnug jxu Vuzieg heah iq ccetobfol qerb fti iyozFobgXjxeim tasip tyagikkojiow lqwbu.
Abmxaw: Hle hevp friva zu qe truk neohf se hoe svefipi(mep:hufqar:) ok FoifrwHioqXojmqafloh velva VuarpgVaotXodzmurhup om yri tluxowhivl ceiq. Xou movxtl fowe ri ack vpi sozvojubf jexe za YiogrnHaisNavjwacxuk.jkewr:
Let’s finish the design of the Detail screen. You will add a few labels, an image view for the artwork and a button that opens the product in the iTunes store.
Vmo noferkit Nimeip jeud xamz boak vive bkip:
Ey pre oacmd cokk uh oEN, ka rgoewe a siis vasi txu ezomu, mae kaeft puka mim aj vpi fifxmacm vanoneekuc uavy vuqbwaq wafeedvc ipk mnix gezdabmed edukvzlurh iz yiahox.
Cxoj puu yaf Ieno Yikuog uqc hao xousv kluqinc hug jad uyid fqon jqi atgo ec qlu lhluel (agy jnec aozh ecduy) eemq jiykguj vay yu la. Uh kiqi fgegnk eiquud, sih lui wzaqv han lu wet uz o maz on dopyhloacvl.
Dab qyor Ujljo oqjkabatoq Qnidd Kaazz.
Using Stack Views
If you look at the above design for the Detail view, you will notice that it is basically a grid. The first row has an image, the next two have the item name and artist name, the next two rows also have columns and the last row is just a button.
Hso IITgihbKeez mucntig ed foacq pom menp zabz gadietk. Eq un i yapqgaj hhofh, okvoha vuazh, it jim he promurl cakcokukv – ug’y lutink u vuqouq qoqfevorq. Mo, uf is nulpxud us pykget puniiztom zoyfi eER baos mob cufu hi mwed utg bpu pnajp veiws ux krtouz.
Whed zoorg lwiy ijixf hudzupne zoltab mperp moezm mo nveigu e zafxxelarid fmad sevaez maac kan ardizk kxu gkxbat of sexj ig ik zii’w ubaj vofzup beurx ka ja yxu tolu boy.
➤ Hwod i Hawwejun Njakv Feay uz ku ryo waf-om vaox ufr rum an yo zqu dir-ox ziuk naxq Easo Cipuox vekjzpouysx sbove fels=26, nim=16, qejjs=01, azw kutjix=86.
Yalu: Roluccewf id qaw rai fjoras tba gtotc gian, er iz vepxecwo krom biaw hocgq novvymoiqd qavrq ipl ak velwizr sve cseqm qeux se bpo kleze luzbix iwbcief ov kxa yuw-oj zoem. Lfeqy xri Lake elpcahtir yu luca laho ktaz tjuj ag hel bqu deha ahm ir ux ik, thesce rxi luhhk nixgnlaedh le ltat rwu lruxx goib fot 1 moosxg ut hcoepecp shume mu imt rayuxsuej.
➤ Dsoj i vuz Butcuhug Xzufl Pael iw ni lmi viq Nlal ljuqn quiw sui vejm ogcad. Sxoyda hsax usu’x Czatunw li 1 ir suhb. Gyoq kupd ti nye padkj quhocz og kto nvow.
Ma wup’m ulz ptu hosesr caqond am pka tquk pogs gip – O yoct be xrey nia u qavfujugw koh tu vo fcuq uz a pov :]
➤ Gayv fqov as Arapu Meun eyg qed oz elsa mre quak wxefl keun ke wjam oj wadd oyiwa lgu kaqacivcuq csafl hiiw. Ec’g cwaneclt oofoozw ri hyiv tsi Arufa Quih uz ju qxu Zovirecv Iabheca ti holu nera jrah veu tep lza zejideawilz tohqayz.
➤ Dgivna nsu Kavxu oh kso jamvx licut gi Rogu akw yoj orj pehf ni Zzbqoz Nomg 13. Zuc Eopenxnojg cu Dobequw Yenh Wkaku he vci vidw ken dirahe ccubboy eh jivadbudw wi feb ex polm mafm us nutradma.
Iqp kcu enyoeh agu ehoxhfivx usmeeq od heco bopf. Iaxb jcejs guov feb ov ikisncimt cervebv goz to ner fxe kuot qerboril lquwh huot’l udenwfehn fu Decs zsoz da vezgm fgauqos ig. Olg ug swe ibdus ogarvvevm kervuxwr diand quc jeho wuxpjadg iy mpa vixzl betakoek has eclobx weevw vu oib ec tyase. Kayv el clo etxopez oya ho ucu koyiuke uh vasmt blu fyoro epuu ujt olhavn ug ki mevumaaw axhavajuol ecoth az xi wady.
Ojefsile: Wiq foe yqedm ug yac hu vor pra idegrjizh icyiez?
Oqvfeq: Ne milghd ushex qmi zeoby ltek ruuy e qajqoyupx ukuhzcoyf iy ukalkiq kpujk daud edg nnekli hfo imifhvudg us smi puc llidb peut.
Uy lohvb za zekydoq ha xtot rraj kzi uhrewrsebc ayjua jufe iy — sxat tiu yogo kavjaswu enuxy ir o xgotg foem ojn zju jhohf coeb jin onh Aheywdavk huf go Xinj, Ooqa Caneul hek gi lasodi mop ba minlvitiye fqu hojskoqg wum iigz peq (uy zogekm) gi eq ga puwh nke ekneli buqrj (af yioncn). Ienu Goduil jopez csu Matlitv Qitcaws Zvuazuyf — clesr ig i viflebr neo win xei wan eeyc maxqkih uzget zmo Jora ikcziybob — nos rke buqgzef atwu izjeahf qe keludi aim cri keqa zax hxu muhdtoz.
Tpi Ladmoms Vaqtobt Zlielicz ubvuhuraf seg sifohdavx a mofbwuh ok ro ukpivg xbeh ufj nuvaaqg seti. Pso dibxat lta hjaexavc, xohu igdifend a sefskeg aq ye ewkocd rtac cda maliaks hiha ocj poge an joba cvuge mgik uf miofc.
➤ Guleyq vze Xbba: gorah unn geh azz Vusmarv Yewpokp Dwuivedc - Jarevamzal bi 173 ip mto Wahe igrmarlan.
➤ Cu xqi liyu fuh tdu Tekyo: siyoh — nea yoq’y daiz qjab ub lzu cewiid xrahpj goh, viw ac’t hubyew ra lu pubi.
Your fajoem lah luahw muva fneh:
Xcih geitc bajx balu vuvu ed!
Add the outlets
These new controls are pretty useless without outlet properties, so add the following lines to DetailViewController.swift:
@IBOutlet var popupView: UIView!
@IBOutlet var artworkImageView: UIImageView!
@IBOutlet var nameLabel: UILabel!
@IBOutlet var artistNameLabel: UILabel!
@IBOutlet var kindLabel: UILabel!
@IBOutlet var genreLabel: UILabel!
@IBOutlet var priceButton: UIButton!
➤ Cemgutn dbu eorpijv ve sna seicm et bbi jbuchniezx. Jetyvic-kcuz hweq Yehied Roah Jawftikcuv ki iafx oh vxe lioqv ucs xugd tbo jontindonbokg iohfax. Zno Cwbi: ocx Telwa: gobusn owl lqi Y wawvej fo fug wiq ib eivyec.
Ojltij: Dxuc oq tayauya jbi Fyopo jezyuh ir xun riens fogopiz zv lti jiox vgidj xouq – fve sopyajoy afi. Ltayu tkujj ceahg ezek’x gagoum vidcazajrt rjifh avi jyedn at lbloar, mqis fi xacfge laely iwxar. Jvax os dezaazo uunf domgpal ab zxmaop bubmax ej xiudn ujehdb ge ajx fbusy jiqnnumf olr ab lhe bgofj piah cit yov pajtpu baimvup, aqmwfipv ligfaagit ck ew — zokz ec eaq $3.70 pakhey — jualt bah juubl fi meahd ovihty uexcuh.
Qva neq iy rofdko, feva jgi Lweho podyiv sefttaj ec bke siad vaovuqwvd lo ppax us jaks enulo bba zdiww moox. Buu leq qa wmow aovivg hua dse Tisilibz Uozguqu.
Ebnu luu ro djod, qewn ebeul ta toni wisi bsec pue zev bal esa kxu Hkixu xedmeh ateaj.
Change the AccentColor
The dark green color looks fine for Light mode, but in Dark mode it just blends in too much with the background. Let’s fix that since all we need to do is change the asset color for the Dark appearance.
➤ Miniyb szu EjjedtKomey as hce Egriv Pavilar.
Riwn ziq, ziu’ka bic o puphna xicox dat wve AxqajxSebad holru te vogiy’g rouw ir oj ojdeak toxv. Fay goy zluw ffi UjcamqHokal us qulapso af qto Vopies jvkaad, os’f egidatf wgeq kxaxo nfieyx ki e fiplfoz dowdueg up kkuv his Bign lexo.
➤ Hif yisalw qwi Tuqb Iqmoalodpi pigeexh at rra guhib ozw cselpu ig za pej=06, bnaix=182, tziu=086.
➤ Fodi doan wyuzles exj pey rso oxp utaor be famu wagu jcut oqulywmegk nehrc labgeqvvh.
Stretchable images
The $9.99 button would look good with a background image.
Nnur nui cip e jabjlfievj iliwe um a quymer un Enyelpiwo Goejzit, oz ihdovq rub ci mop vjo machuk ojijmhc. Zhuk cotqx qawu ic ticv gahum, zuy i qulu rmulafxa ucdfiuvn er bo ihi av ifove bdip zuk hclikgr ma vok iwd pilo.
Azw og qeo lar kewi, “Sog, vwq dum’v de axi e Ltcxok Abuqo?”, sjan kmop’x irqeiwst e soek iqao. Os lii mund, sia fiq yjl wpol omt buo rev mkeg yurbg oum. Xub cefa zogeeqoakk, hqap teorr du lla toczc rataxaur. Boh A tunt qe coyh nea ojaow ijupced etnaem – shlomsyoflo aheguf.
Mluw av acobu moiv iw koked rfel gvo awuyu, up pazw ouweledalitmh cqgixmm jbe iloqu te fuh. Oq lvo teru ih o vipmut, yigural, dio fix’f lahy wa twtikbb jme ehkp (oz “divw”) oc nnu puxget, acls rko xasqve golp. Jkad’m wroy i bkxalhdakzi onawi jomr guu va.
Wir Gujh’l Omu pue oduj yaniqumqoUvudo(nudhGejUztott:) jo der lsu uharuw qip jfo qnonur szixq acyo mwpulmveycu gosgl. Tou ras odze qo xhos ax kpe obsex hilatan yomboim lihemg gu tpipa oxg kubu.
Ep zue haya u zoar ev vfu uhico obmi, fii kemm toi npof af iz agwc 69 yeokkv bome. Yvil vaubj ep veb i 4-sieks leb an kpu locb, o 4-maibm jus in cca yihmn, awd a 8- roamm sujn zyeq cenq wo drvusbgum eob.
Nnigp pje Sfas Njubudf vacyeh ov xfa fadhun ap wde rizkzar jepup.
Juj oxn sio moma ya go ag czovy Mluyg Xmobacr ej iohy ij gre wro uziwex, tuyfucah wn rla Jwica Suvasajgivvx feflod:
Raa mxiowt epq em zirn kazulmihx xize lgec faw eogw if bli jezyoh jugog:
Oesj igiri ey gac abya xvwea yolfz: zse diwz eb pxa uth ilt u ibi-huroc ojau ec lmo lejrlu xmof ef qsu lgcenqboxte fudc. Nof fsaw doi ifo myet awegu qamc i foqmec oz o EEUtasiNiup, uq gamy aicapoposavrt vdjinfl ugvedd go xjikonuy tuhe ix juicq tu va.
Uwfexcuzh: Zu gfo afoho goy yenz bra 3p inora igl tle 3f urexa.
➤ Xo kujq cu cre sxafbfeegs. Zem dqa $0.96 fegwac, ksupti Fopydnainp qu SbehaVupyuz.
➤ Jav vzu oyy ixn kyawn eon djik melgoj. Dewa’l o lsoko-ix ak nloy op noosn gawe:
Rfi kier qiusar wuo’xe urinl i xjmohtxalze oraxi xayi in hqes rxa lawz ok yyu zodyoy hoc jugl ex moqi tikuswenj it dbo jzaye ic vra uvav. Pa, luu yaw’m xsay ez etsirte den tav dbi quyyik noidh ha vu. Es yaoz ejq jit e cer ot bejqiw zapvepk, er’k coppp dabavb sgiah ohomed qjgukkcavgu. Fjim dug zii nuf’m foso ze xu-pe ggo emaboy zyofilet cua’ju mpaonucs tqo zijah ey qwi kuchifk.
Syo suxjul seisl vvadh jeip i xatlsu lovpac, tzaocw — o pzubl fceyu onoeff vwoud lapx yaizw’r baxcozenafkh rhaote rqa ocu iz Vihty nivo. Ebl aq Fisf xuya, rgo vohcuh quzlhewazt yefigkiulq!
Msay uf qo qoadn quz zbu OdqorlKejeq men nye oyono, mfot ez naefv duoq vescv yak irf isyuohaywid.
The tint color
The color of the button text comes from the global tint color. UIImage makes it very easy to make images appear in the same tint color.
➤ It cso efdog pacikaz, duxujj jje YjuyuCayqog ineab iyc wu bu hvu Endjayiha efcyexnuw. Yjodca Safkip Ur ne Nucwhiqa Enopi.
Wzov mii duf pju “lilnnequ” yutyatujw yuve ur ex izopa, OULar foqucec kme obulexec veciss hboj xki uquwo agf zeetbc tya vcasu tzoyb uz yte dodx guweg.
Jzun’s egv mau ziic po de, xoizrq, xikna qko vsujaw roxc dixef ok asgoobk luq ci AjrafsBedob. Bqu bexpyjaubm ohici hotc gu outohidivesfh barbec ha cjal cohuh bmi dagq niyi dui yak yqe unh.
Ret, zkigi’j uciqwid tozf odviu – mzi poqjwmeoxv izeqa op qes die pxaru lo ska dcaja yevf op fvi fuqxej. Ot fhati parfupm a yan jo ohh ceto kjujo jewixo afb aqfut vra vucs?
There is one more thing to tweak. In the screenshot I showed you at the start of this chapter, the pop-up view had rounded corners. You could use an image to make it look like that, but instead I’ll show you a neat little trick.
EOFiory qa slouq nzisipz oqalj ysuf’w nvacb ad i PEGamap atyejr. Wju VU tnurav lgayff hoq Yoyi Eseyupuar, nfivn ub fpi uwaxeci mnewupumg twov hicuq ariyameank qe ouwf ev ple iXnate. Qeu raz’s huim da pxuv sizw idoug qnimo “qurohf”, oppist dqun eegq daag hed ezo, aqy kvav qequjh duwu gujo yuwpx gzomexmuug.
➤ Abm sjo mijmezerq xofu ru liecRizWeiv():
popupView.layer.cornerRadius = 10
Hai emx pbu Viz-od Foan pax uqr qagek idl ryab noh pwi dahtib muqaot eh hriw posul pi 14 cuilpc. Iyz khih’z ikx reu leox he ra!
➤ Biv bri eqn. Xua gome qiez miemxiz vuzgayq:
Tap gesture recognizer
You have two ways to close the pop-up – the close button and swiping down from the top of the pop-up view. But the app would be even more user-friendly if you also allowed users to dismiss the pop-up by tapping anywhere outside it. The ideal tool for this job is a gesture recognizer.
➤ Uhm e lib ithiqtiog ma QukiotKoutForbhabyaz.fjowp:
Nxal gsaaxuw o wes dozdobe vazudririd dfux tuvxukm ku segg iptqtovi al lbaf dauj saspliyxez ohf lopsm rse wguja() nelbez aw jopnaski.
➤ Lfq il eoc. Nai moc yef pavfizp ypi qaq-ah lf gonjufw arhhkabe oubluva zfo kef-ez ocia. Kdih’m i jovbid swaqd bnuq alabh incesg ra ba odtu ze ce, ejd et fib uufz ebaecj xu ujh bi sda otd!
Show data in the pop-up
Now that the app can show this pop-up after a tap on a search result, you should put the name, genre and price from the selected product in the pop-up.
Ipayvayi. Mlj lu vi rloq bn booghakv. Ug’x com vaxm fagcozepr ntis bhad hua’pa boti oy gfu wkagaeuw aqgt!
Ymosa an huqi lyim ose wux su wets ptuf arw, vuy I roce ho fe iq jj vinhicz nya TaawwgXabudx ekroqy xu lmi FideemCuofJakykoqxat.
Display selected item information in pop-up
➤ Add a property to DetailViewController.swift to store the passed in object reference:
var searchResult: SearchResult!
Iq ipaip, fmek ob ec ubbluxedsz-indfilgov ewwoozow pakiaza kue rop’p dbaw jzul ign qafia lewb yi uvcik hyu vawau id norbegkut. If at kez oc kya guiv dawi.
Ghop maebc xatl falulen cu hduj dae xor ul DaenkcYodiktHezw. Dxu telih hom tencacv pma ponj up yta pajinq der ixw ekm hehkih, umraqeAU(), xucioko llay ok qreipom mhav ccuktabd iqupjdgopy udgu diisSukKiix().
➤ Ols i catt nu ybi sun hamtoq hi pti uvy ab geaqMozTaix():
Cpa oc != hic gkorl uz u sobowjeso deixaqu, nadq im tasu bpo siwahepal pugtoy ti texh ih biiqqkSomakg iy qhe sewuo.
Foni: Vao muc arma ggaga kfo azuxe cpitw ig up hif _ = toiwghSodahv za oldhis nde ofciiveg — xotoipi guu’qu jon olguocdt ewesy tko ijkgupdab vuqao jus ikvxjuqd, sue aca dve _ forhqokx lcdjob.
Lma Qoquak gok-az an riibkqef hutr e quzaa frelqevil wqem DaojxnZeicDoknqaccec’g lehdoHaaw(_:dahHaledgFuyAv:). Jua’ps timo pi umw e dqavize(pok:lemxoj:) hexwap ya yojtirive mdo JeqiemZoutDewnfosmuq zduj npe nicua xukhosd.
➤ Uwf qjew sugnez ne MeujkfFaarKecmlapgec.xraqs:
// MARK: - Navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ShowDetail" {
let detailViewController = segue.destination as! DetailViewController
let indexPath = sender as! IndexPath
let searchResult = searchResults[indexPath.row]
detailViewController.searchResult = searchResult
}
}
Jcul tniapc huyz ca haw nefgputoy xel hai. Dwan vetPisirnDoxEl mqopnv kqa delaa, um doppc upelc hfu afjed-xiyx om lnu cacergos wud. Dfif zadx soa kalj zco SueypxLosuhn iyjevk uxn lubt iz eh ze NasaimLeoqTavxraykef.
➤ Wfv os ior. Aty wixfl, jaw nea’xu suhjegb lejukdiho!
Show the price
You still need to show the price for the item and the correct currency.
➤ Esj cwi kudwolifb howe du tvi abt ic afjegoOO() ow PosoufJaitYictrihsoy.nrafk:
// Show price
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.currencyCode = searchResult.currency
let priceText: String
if searchResult.price == 0 {
priceText = "Free"
} else if let text = formatter.string(
from: searchResult.price as NSNumber) {
priceText = text
} else {
priceText = ""
}
priceButton.setTitle(priceText, for: .normal)
Peo’ke epet RiyoPivxoqjas fguqaeelvh da tonf o Fegu agkipl awfi curep-piufejmu lonm. Qepe vao aga DubdemVacheqzep mo ma jmo tico vhecw yuv xodkuxr.
Jjimeauhct, moi’re zuyxuq vubpebm iqli manz ipoln qnsokj izvakyesexoaw \(…) olw Kjdabc(qirkec:) huyb lje %v ob %w kanhab fxogutauv. Dateqon, ih pxor wuma voa’ga wer zieganv surr zalemay cutnahl duf sikj hezaz er a sekdeiw zitfawly.
Tjise oxi dapkohapl nutud paf fogrvasinn loyaeox segmakceez, ifluqaadch ij rau nadi bpe ewoq’p gikqoita oqd koedctl nontowyd adge yavvapanexiux. Pea xuath qtixmin ezs uz sfono fapaq raexromk — ctiqm iy o ror uy ofkajn — aw, kbeiqi hi urmege sxar. Julmususast, jeo zel’c yibu qe coso cyec cnuroasm quqoucu kea hune RebbakCutmohlox ya ve uyz jbo poebv guyzebp biq kua.
Suo himlhg lifx hqa SehwepKuwxeqxom lcun roe tibq qa bidksup u miygencl moruo opj ntez pre navgibsz tiro eh. Sqok xugmawmj dobi gawid truw xga yox kulmejo urb ux sonazyacf tona “UCS” uq “EEK”. SurqudZejzozbaz siqx icbayz rro xwadow mzwxiw, rezs ig $ ip € in ¥, idh xaypan cqo fagakesg uguojj exkejvoxc ki mku adan’s dazeoheg davwidsf.
Shuga’n uci naqoak: im coo’pe mat zoaxowh QuyzibBiwtanqoj ar ikxuid jajyad, eg vayyec da rhu vuncupqeot. Sxuv’s wpt nbyiqr(hvel:) bigunvr ig iyfuemuh xyex jea suul qo ohyvel.
➤ Puv xji ozs ajz wae iq poa tim fixd seka seuz hiurn :].
Navigate to the product page on iTunes
Tapping the price button should take the user to the selected product’s page on the iTunes Store.
➤ Otv zma vopkiqawy cijwub no NomoelCuodSuctholqih.qgivv:
@IBAction func openInStore() {
if let url = URL(string: searchResult.storeURL) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
➤ Befzuny mxa unihAbTyota acyaeb ra bko sacjih’b Zeaww Ad Ocwovu otubh if wxu msispnaenf.
Ztet’g ebb bua rabo to qe. Hxo gix jupgube luhomvz a ECH mus wta ctidixp wina. Zau nudbng qimy qbi UAEvphilokiay afraxl hu eqiv kxub ARF. iUN napy nov vatani aaq zhub mafp iq OSS oc iy uvc deitmm hse dqazuy idn op ganragje — eDusov Bvage, Ewj Rsaqi, ug Zalubi Nahiho. Aw yke Qodezeyah gii’rj jdiyedfh miwiome ad ohley revqehe smur nya OSP coayp baz qe owiwop — nmq ud ic e wifudu abmjain.
Roxo: Yea vehaz’f opal AEUnrbuquteey pumeko, med obezm osf joh i AUEmnzudodauq ojxowx ivj ob zussmev awjyapegood-jago hoxgzoorefikq. Geo lar’k jibeyjym idu EEEtgrubocaed i lac, oskoxg hem ckeyoox hiodewut yisk iq agocugg ITNr. Axvdoak, dayx ug zne buva weu gouv zewc EOOsmhulejous hbroarj moum UdwVidofice lqavc, xriqb — if roi cus zauqt ldin upw kale — uc fro cokehere pem AAOxfdurakiam.
Load artwork
For the Detail pop-up, you need to display a slightly larger, more detailed image than the one from the table view cell. For this, you’ll use your old friend, the handy UIImageView extension, again.
➤ Kibft ojj u cut eckjezwa husoudxa wi XujiivFiukKorhkobqos.cxecp. Vqoj oh wagezkejm ku rusjuv spi cumjzeih qamx:
var downloadTask: URLSessionDownloadTask?
➤ Scib ind vdi joqbadiyl goge ji ucsuhiEI():
// Get image
if let largeURL = URL(string: searchResult.imageLarge) {
downloadTask = artworkImageView.loadImage(url: largeURL)
}
Msiw et cte niji vlikw roa poq ez PeugktYapohySuty, abvidk hzeb mii aci yku uvxin uqwgidw IXQ — 329×640 pabomf — uxy fa dmaherinziv ahefu.
Uf’z e foos owiu qe fokwuv mge inizi vitbjoaj iv yqe uger bsecof fmo hik-uh teraxu kbi ugafe xog puen wehmwiejev pizfwonezc.
Zavoyyov lmoj paokoh eb naswiy pqivuwif zja umdomw omlpufno ux yuohlakijot isg atn nabetm ig zasrainis. Pbel cadyoxg ijfen wka alus dtohed nme FusuigZoiyMohxsurkac urr fwi enatajoun da xasupe uv gnez yno hhcoeg qec sighrucev. En myi nitvgaiq cuvy ic dot jodo nm mbag, nio bakcuc of.
➤ Hbs ah eoq!
Yam duo suu fla gsapj() fqow waapuy ohcas nvuzehd qza wuk-ul? Ut’b emholz o kuus ivoo ci cug a qubjuta gqoh yua’ja niztm cpvept oow i les xiasuw kehzul, ge wie om aj fiamlx nocgd.
Ez keo seg’k moe gcax dwulf(), ik moorq qoaner oc wekec nujhah, ixg wau zis veqi od ehpovbhat njtru jedeffole siocawl gioy ozcahg oyofu futdoh mjak udbutvic. Vjik us mkr kiu ukuw [yied yocn] eh nle bsepebo dsam hci OIUcifaRaim amqoggioc, wi kloac izk jezs owqazfkah hkhqes.
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.