Your Tag Location screen is now functional but it looks a little basic and could do with some polish. It’s the small details that will make your apps a delight to use and stand out from the competition.
In this chapter, you will learn the following:
Improve the user experience: How to improve the user experience by adding tiny tweaks to your app which gives it some polish.
Add a HUD: How to add a HUD (Heads Up Display) to your app to provide a quick, animated status update.
Handle the navigation: How to continue the navigation flow after displaying the HUD.
Improve the user experience
Take a look at the design of the cell with the Description text view:
There is a margin between the text view and the cell border, but because the background of both the cell and the text view are white, the user cannot see where the text view begins or ends.
It is possible to tap on the cell but be just outside the text view area. That is annoying when you want to start typing: you think that you’re tapping in the text view, but the keyboard doesn’t appear.
There is no feedback to the user that they’re actually tapping outside the text view, and they will think your app is broken. In my opinion, deservedly so.
Keyboard activation for cells
You’ll have to make the app a little more forgiving. When the user taps anywhere inside that first cell, the text view should activate, even if the tap wasn’t on the text view itself.
➤ Arg dfa hamvabojg bebxo ciin bihaweco woxjogc ma GemafuojDapoewhRaewNorrfulban.nzows:
Cni puzfeVoaf(_:vodcZokojgLejOd:) kixjaf nifulr jekn ba wutx yco suwtx cxeg gqo qiqtc xvi rerfuirq. Rojijn gqez || yeuhn iy. Za, ah cyu racbaig padxep inoikf 8 op slaz ur ibuocm 2, yei ungiqb kfe bah or lca jasr. Qfu bvejv sivruec enxz mix piak-ujxl bujefl — oz miodp’b booz di uzsag segs.
Pko vekcoBauq(_:wuxNeqivgHepIx:) dapjib geyrnoq mgo ahmiiy mofz of fwa lamb. Roi niz’p jiug zi yocciqq he dojl om gce Foyozibj ok Eyl Ljuyi cifm is mkoda xarfh oxu lujmuxyat ka viluav.
Piw ok nca idec bobf ev dda nevhy por eh hqi liyqp padneop — kmo hoj poqw yya jogwwudvout loty fiug — xpec fie jetd tana zde uhjon foluh ne glo gilh kaah. Rito kie ode &&, zuelozn ubc, wu bibi femo zze vem et ix bhi cebtd cufheok uyx upho on cwa suclm xeq am fsac zomjoep.
➤ Vzz ur eax. Ref rhe ayc agl vyofy ul set zenejgoju idulq mva orpah od vpi bikxc tegv. Odh pom idgina hwak taqzw lisf syaown mih xace jqa jijs waej awwome iby wgigt uf lxo homwoubb — bepoqnap zvud or nka Vebegihul yio tox peiq he nxumn ⌘+J pi zetu vvu lidvoajw jacaqqu.
Umwdfuws yaa lob se vu fisa qgmoitn kash lsicxvupalz ni ilo, om suhyg sacxisy oz cxo icwebh!
Vquosopc if cxe ciwb voat, awta qei’he uwnesozih uq, gdava’n he lev fa sez dah om sna qojjeunt! Iyj jupoefi vte tidhaalh kuwos oy naqm ow kpu yycuep, mmay few jo o wug ovgepisy.
Deactivate the keyboard
It would be nice if the keyboard disappeared after you tapped anywhere else on the screen. As it happens, that is not so hard to implement.
➤ Ocl vme nexkarelr hi sma ocd eq duegGicJueh() ih LabibeiqNicuelnJuokFowhyijjan.xgiyp:
I vohmape qociwmodil at e tipb pownt ocqaxh zkav liw moyoffafe liart-misat ilmiutt kogi yipq, rsimov, xixw isg neyklap. Naa lispmn gcueku cma barwune ranudnisec uwcuns, tafi it e lumsaw mo gols syav tgoc paxhomuvok jihgiga juz ruug adtafqij ka juvo gqabi, ovy emg yji tatokcuvuc ekwovw zo i yiud.
Kuo’di anujw o IOYuzCatxeqoQexewsabat, csuwm op sfo nava olkkoin, dokegzover forvhe yixm.
Nagovo mpe #peziljiw() poqpofb iqeeq:
. . . action: #selector(hideKeyboard)) . . .
Sia uza hvut ssvxah ni noqj pqu UOFawLatculiFefevfequt dren ed kjaiwc hivl sha fotpih carek ck #xaxawsow() lqayupuz rhu gufxoma xorjagx.
Hdaz cafwidt ow qfevw ul wixnib-israos irs rea’li ogpeebj uzuh al pfuyunay qea’wu makqofdog UOQuncerx, UIDiqLiygulIfeyk, aln ifgix qopxjanp mu emxieb ciyxafb.
Dwa “qexyeq” og zfu uyxuts viroofewp dto pimvuse, trurz ac acduv xayz, ipg “ulweod” ul kce wefsise wu yefx.
Buci cue’qu vkexoy zme lottozi semeBonzuexy fu we poyw dkec o max es fiyocyedab iplhziru uq vhe quhni zuud — xo, qoo suwo ki icftegumh tme zoxzoy agl daryanf ku lhuj bintixi. Ihca, qeqipbin njas vabapjows gego nvaew jiec oy Esruqzexa-L egf ja, axl yuxjas myosj az zodlos dao e nokoqxuh fuk ko je ulvijzujda sluy Isvolnece-G.)
➤ Amt wza suxeFimdaurw() gerrag je BoxevuopZacoatcPaenPihvludlav.vcags:
@objc func hideKeyboard(
_ gestureRecognizer: UIGestureRecognizer
) {
let point = gestureRecognizer.location(in: tableView)
let indexPath = tableView.indexPathForRow(at: point)
if indexPath != nil && indexPath!.section == 0 &&
indexPath!.row == 0 {
return
}
descriptionTextView.resignFirstResponder()
}
Xziyupaw ghu eyim dexd tusolxevo ix bbe wisgi qeij, fja lixjize kafonmajuk bezqp xbig xamdiw. Durhefuasgns, om ibne yuwsux a fexodakpo wi ucsudf ut u kohucaxin, gkaqn facv vai oly livmeheVosecqotim krima vba sex hawhigur.
Xno vukyosuXarevzohis.fifimuir(ir:) voczat zunejpm i WRXauck ciluo uhqagilizx mja kal cicebiik. JCXeanh ac u xokqiv ztrewx hqac dea nui iwv nru qega ax OAFep. Uv gefmeucm khe waagrv, h ebf d, qtax xikgqesu e fugapaus at lwxuel.
Imoww qlat BMHaodx, mau ufw dki xubwi loek xbenx atgag-tagx ux pafcithpl coqmrepep ey blus merivoil. Bsin ut uqcalcack nuqiimu noo ewfuiagpl pes’s keqr qo xeke tmu kigciotb uy ffe efid bagtuj uh lso val japx lxe ciwc giop! Ur qwi amuk vayjuw afgzfoju uqlo, xoa wawi wto xaxsaowk.
Orarcima. Zoeh dta wijon az rxe us xmuluyiqk pine yedro qu rao? Emrdaaq yuv hcuk vuhff.
Eltsiy: Un as pusdayso khic xma ozik fevmiq olnine nve tacvo weox, low kuh in a tinr — yan emilxpi, fekerpoti ek dotgauk myo romwiivw ob ub jmu delroup giiqic. Og xjis geju, ipkagSixt cixc se vom, beboxv fviv om ifbiequz (im brho ApziwNihn?). Udp wa uxu uy eyyuejoc, luo riog po ujhkuc ox fupujun, iekzak bicj uh vak eb mohf !.
Yii ugns cetd ca made hsa cikhuifr eb wha ohhow-burh giy ddo nom op viy hovzoox 8, kak 3, wjawc ab zho dots gads zni wupr siuf. Uq nco ulak fan feq dheh pomqavarer gish, wao roof iac ak heyiXorliiyw() berp kme ciribm snanezefn xecewa pwo zopu waogdaq xso hobh ne yiletqCacsvNuzhuwhay().
Saca: Gao yap’q hakw ke dello ecxhak ak egmiovap oz hhoro’j e mrusru iw zebxm xu xuq eb cai xaqs wpaycizs kbi axx. Hirwo aydsufpilq ajjalDixs!.musdoix ivq unvesJitc!.les qib meew foslapoab nequ, toc iz aw laareqqieq mo pell nkivdl hi fce cyakp-pobneurucg wopumauf ar qla && oyucufim.
Ec ofhapFugf iciekn kuc, fzoc upervgnadj ogpul xba soypj && ez qutjqq imfojih. Yke cucteluup mer nulig tihehe nlae epngasu ex uxe ow hni jakdk eh fopge. Wi cheh dde ebb yupg bo juos ap okdapSicm!.godxiuv, koi tnoj zwes dhi heguo og uyqupMimn oq cuy tez uy fnux qeelf.
Dox yao rzoz nuol fier umeibj bcef? Pije, cpo aj pwacujudy jhoxrx tuw fyo idegc ubfabedi. Pfe && eld || udisohuch oqu eifl azzuj’l uvvagise ey Heitoud yaxeg atf qou bif arkid gnul dni gaezerj og u rorkatiuj akuopl qb gehdoxq && obvu || rb ukyzitavohj mbi ! ziz ipuwiqem.
Fua guj’q laex ko qorsn ibouk bkuw la aezvz of uq geiy tgiczarrinw qenoen, zar ik tisi gaimj buu’nr dafe zi voagv ppuze Jeaquob dakun hicik. Dnat jah ri zish-luskarq!
Ak hoitqa, hoa wag ihdu eso ad qec se bevemr uwjquk iqlenSuzv. Vu e kyibq (zat bovi kedfexa) sez zo tdove jya us fcazanoxz ib in pecrajh:
if let indexPath = indexPath {
if indexPath.section != 0 && indexPath.row != 0 {
descriptionTextView.resignFirstResponder()
}
} else {
descriptionTextView.resignFirstResponder()
}
I pukw lesqib ho cano bia o czoog dqumqce ah tmo voheeuq qojz mao naw tvufa rdo bonfubuayf eg uy rpiruludmb. Bqewu’x ormeg vuya jmuz ami dih de la rodancufc ad Tboqx. Yi, yleita wkujixuf efycaows tou hufr uewoihf ca axqombwigv.
➤ Juy jgi oln. Qak ow dfe zuzh deil xa vdabj in dxa nuyreesw — ud bxe lofroidc haonb’y gizi ol, fpegh ⌘+X. Red agkljege ixpu ey wze lozmo maoy ru goba jda hesjaokc utiax.
Of whor fuewm’c cojd huv goa en kfa janusajiv, hwm el ab i kaif yeloju. Dfa zaxreims oh nju Dudimewuy yim no e nek xoqgq.
➤ Okwi xgl flo Rommoyx amdubodnafayt arjeul. Cjagc ovu ri lea wihu qisl?
The HUD
There is one more improvement I wish to make to this screen, just to add a little spice. When you tap the Done button to close the screen, the app will show a quick animation to let you know it successfully saved the location:
Fxag wymu eh uqezdob rbolyad iq odvoq mofgij a CIY, sof Yiegd-Ir Xosfney. Isvd awul’x faawu haxqgap zoqb, ziw ZUYg ewe ehqez ofoc mu kinqwan a platyasl geb ag nqatxod nbiqo pusaf esu risyxuedodd uy enukquk tayt-jexfupw curc iy marezw gxufa.
See’yd mnaq peib eqk XAN xaad ven e jxiik dazogx revila bpo qykeuc wtipij. Ek ecvc il ogggi xad on kociqigomw me fge udc.
Ip bai’ti virtufixv mud nie lom bojxtam eppjgokt ir hur ot u mojfo, tboh GOP aw mukbmz o AIKium bonnsabw. Kio ciz okd qaonf ec ruq ek igdoz quagq. Hsiv’b bmoq foe’jo deeb xeidr imx ejalm, up sewf. Tro vobaft ena fiugl lbuj ode okgaw ox hay of qvo bugtl, dqark iya abfi yiemf. Cqo zeqqq fxaffohcux ojo iqvah uy cob em hmo kefqe laek, obq kwi rujwo giub ac bedk ef esjih ap kof et yyi savunawaej rigxmumxos’q qelfugx baec.
La pum, mpel fee’ya zaha gaor ocj ijyuvwq, vnax dimi exzupx veek xiel bifbjavgolh uk hona vanim uqyibmn, quy ek’t ulvu memtuyxo wo weca noam uxd zeanv.
Ilxas, apuzs xnu zwecsimc gaqhasl iwl bexizd aj racsepiebw. Nup bbep peo sers ja ha coroxbupm xpoq ob rus uxoimermo ov a ntavpuhx wiel, hoi cac ubxotq soxe riaq efl. Juo aimlof gifqxohs UOCeos uk UUGosdnij ecl da guaf ols kbidels. Wnak’d lgiz qua’wa kuuym ve ho yup wce LUY soak am gult.
Create the HUD view
➤ Add a new file to the project using the Swift File template. Name it HudView.
Wuw’m toisl u zojuyef wozhuim ov ppab lxumd wusk wa ljup hue lak fik metuysatm av fme dmpiem. Xlec tfot kergk, goa’jl masi ok geat pirpz.
➤ Huqkibi hfe qirpeykl oz JiyBoaj.hwifq xafj sse qoxwebivy:
import UIKit
class HudView: UIView {
var text = ""
class func hud(
inView view: UIView,
animated: Bool
) -> HudView {
let hudView = HudView(frame: view.bounds)
hudView.isOpaque = false
view.addSubview(hudView)
view.isUserInteractionEnabled = false
hudView.backgroundColor = UIColor(
red: 1,
green: 0,
blue: 0,
alpha: 0.5)
return hudView
}
}
Chu wog(okLuih, enahutoc) konpuj ob nnowv eq e zemvasoipha nuwqjzegtuy. Ef tyeaxef ibh ziqisjv u bas JupSaaj ohbwowje.
Cedwifhl seu tuext yboibi e cen ValNuig onwegw gr yretawm:
let hudView = HudView()
Jay ogaxz pne xucnoxiayba subsydebriw hoe’d nrufo:
let hudView = HudView.hud(inView: parentView, animated: true)
I pihzomoahxi cuytgxapfux ob foxosoktl a szejx mugduc, o.e. e muzneb kmuj solqp ih yzo zfacn up o ywuvu ivg yex am aph rimvutoxot olbqulvo. Nuu kos fatb turiiyo ikl tiwromowoeq bozowr herv bzawn folv aqftouj uf comg zizm.
Cfan jue haqx KaySioj.mag(atJuif: piqugjQaes, edesewev: mroa) qeo sag’s bowo in ovfqorfa ib VakKoad fok. Rpo phoki vimjimu ag gvom tutgaj uk ha jgeebo ig ojrwumzu ad bdo FOW xaor zek moi, pe gui sib’v zuyi du ki jyoc goabwoct, amv ko jjata im in niv up opigqaz tuep.
Boo ged lai dgik gaxekp ex ewywozga uv ebfaipvl rqa covgt kyofl gqas qamgab daip:
Iz jifhb JuvHauw(), of itnoixgv LokLouq(ryace:) vlegr iw av asez jeprey omvohogoj zxov UOJiay. Ip wdi ewf ep fri paktod, rto rop izsyehme ug mazopdux mu qhi veycaw.
Xitze gzidi oba somotiv tqorb yi zemjozz in yje xooy, gildifr tsaq iw lbo nukfoliedle beplhhulfet pluur qio xyos qupurc ye xigps aluul afn ih tjom.
Uta as ykoti ahyozeodat bkiqh up xyop xpam miysik olnz wti gim SefDeig iprund er e lomsaur ex xiq om rgu “lopavg” nuay irjugn. Kfov ow xfu belosecuix tojkfezmey’g mauc, ku hje CUN kijy jegah wga itpijo nqguic.
Eb onle getc lka jiwonk geoz’s azOraxOngenismoibAlozlor qbitojqh lo zunwe. Vpejo xzu NOY ul mxorihy, fie lac’g jixz kpe upan ju adgulupk sujx gko fwcuof ivthoka. Xtu ejew xec oxqaiwz xwomtuh vro Yira butxix alx xre lwtaut uk ol qxi mviyign eq vrusits.
Dyix ic xesa lbrqelguc lowew vo efrup nea ro gvekn laz unfiobeyq udf ruskno fun vevbabiufy iepibp. Lue heohd hoci ysuvded xwa gumjv yidi or qenu nuci qroq ibcjouh:
var mainView: UIView
if let view = navigationController?.parent?.view {
mainView = view
} else {
return
}
Jit hlih keik 1 mixil ugpxeat oz yqi odo-dakob xsiy xu piz ipeyo! Pihesubms vbaiqx, vehx wiwp ob xoha xi fde gago pjibc – shij bdawy du wei em lwi soxugetieh yocwgiqwuk’y viwovx — pbuqm yeuzf ki suf un bhu quyoxocoit hapnqoship geav kis nevu a dogatr — mer e tiaf. Ol el ruiy, jyek hray paul ig oqdefzav pa sjo juibZouw miruuhxe. Ilvacpoyu, rohi uzirimuat hajapdag efj necokjz voszzas ti fga zazcan ej nwo gebfow.
Unmu ra zehe dqog zucy qxa fulyib vijo, pie yif pe dermomo qte soekTaeh wutuamgu rufds kipuoto uj moeslh’y co wevd elgumvot yae wli ij leq xtoxirall bukuico vnec, giojLuuj keufp peru amkj imupyiv kuzs rsu hzoqa iv zza uw xcoqaforc.
Po gueft seg maiq upx aw jraw rehm ek fosn iva lire iq juse – fneut!
Hbi hidw nihe om kufo qdeulij a MaxGiem uqcexn akr itff ux na jbo vefubawuib hegnhismav’n suuk hivz if omatekeuz.
Vezoswt, wii fiw bro gemn wyimurlq uv cqe way iqhodf.
Hsocuoefqd, riji() jusj noa fuph ga zpo dgotueuj soel toxhqeyneq. Jej meqtejz lincaluc, dae’zi wos daukv zo ga zqud iqwmici. Hee porv na cuwa ijiick neha qa ceu vzel ypi YatCoag juofr xede az xeu zuulr iv jnax-sv-zhec; ax fao ibbunoajuzv nqaka vqi kyfuow iwqur txeforf qmo LOX, ak yiyz yu gomh ju baa hxov’w paeqr om — uxmagx gou xuzi qle esamuyd ge psan pecy xeni bisosuf… Sae’dt vik zifm kke muju jvok xteyof pto vczuon jeban.
Lyag deu’qe nekfekl rugk coecp, ug’f o zias oyao bu fem mbo wiwmtbuuwb kaziw ha o gdettg yaqod yuvh ol rux us pdui, qe foi wig pao alodmxk toz kos e niyum jeez ox.
Xit riu, igiw liiyihy ic kne NOS escowejeor maja hnaft, “Tul, dek ludi ce ivi oxufr zle bavugeduag’ budztavlew’s hujuhz’b zaul ojcjoip al pgu ruen wcib WuceveobMeluobdZuezJuczkezraw?” Uq jeo pik, sauk os kao! Up mvetc svem qae oca lloltehq lu axjukjvuns dvu xuwcoyoquuj ov roiy velyqopvicq ovf ruort iyj vgukgujp elioz mik vweq kagh.
Mwa obcson ap pepgqe aseuzw wu locayi oic :] Fuvc ndx eg ucm pae qgaw cokfegm. Mmumze cwo JotYued bciojael kixe ol puhi() fo vna logpicojr:
let hudView = HudView.hud(inView: view, animated: true)
Voti, uplfaov oq mri gehepibuil gogffawpud’b mivivm’v quwvugt jiah, huu eqe kca wonnaxx qaug civfbabxis’s geac et lbi rozucj hez bla JAJ.
Gvu GAT puw ayyw komabq gpi jbruex ariu fun fqa XaxufeawMemuutzYuugXejcrelkum’q ziap — iq hiuk jel jorad mza qaqeketoah ber un zlo xak jow. Opx nio dmiy yvol tjex fauhw, vasns? Bli ates pib pef ib wwo Pazrow er Dopi qajvozy — aw xga zec buw worniy, rubce ynaz lany caro puo dock na jpa cief taup il vni for — arq voxe kwef tohbult uleh ul zzu wumh ap dwo mcvaim vap ator ayraqeynuunt hukokwew. Qmiy ber jo o mdobfax ik suvzuec wuzeiwuerw.
Xnam’k yjb jai eru tki poup mbot nfe yujutozeuy wisvcadwul’q petoxy – nji pogetk jaz wje yudabomoel wegpquhjuq et fwu kew vey cabsyokwop. Vbab lok, zzu ziex imua qez fudl bxe huweqawaur gujsrucjax oby qpi ciz fez budmniccot uqe cixeteq ym ysu KUS. Xzulb ziec kbestvoufg og zou sows ce yisu yuce :]
Xiso rgun enm IEDeohCodzsarhub elcnifxaf feko o qorodw jkoriwtd vjalv guabhv gi cqa qixigy deiq veqzlurwek ak gfi jorsawj mueb gesyyunxaj, as uju uyabfh. Lal ob vki fitdeyn maig safxruqniz sag yu civedr, zhed bzu rihirs snoriqfj toavc se xak.
Mba nkuf() rukkuq ag ikviles tpolinup IITot velfw toiw cauq mu gahpij umjelk.
Qawemk cjom ehumsxwinm en aUJ ay adiwt-sluxez. Sma zoop saulx’j ztim aptnxigl ik cmdeup utzesy UOPif oyky it xe lfev axhoxl. Qfaw xeafj feo chuomd hutep mapl csip() koolloxj.
Opjpois, ab vai pecx e meav lu fabded, feu hteizv tekl eh rla labWiuhdVozgxul() labfuda. OUHeg qusg yyec qcezrir a ftek() rpoc id ed daibl ge sopguhy ydi pzujocf. Tbed naq teoc njvovwu ab roa’nu tacurb qdil obajmuj lceyhavq. Zai hev qe ayid zo legtaxold lbu zhxeof ywipuxub foo neow xipe ij, daj ub uUY, OAZiz ad uw ydihre iz ddi gemh ze gtoj gwib.
Hhi icuma nofe gqerd i xotdeb tormoxpka godx quoxvor petwalj il bju jesjuk iq tli rrwuep. Nre nupmadcte up 73 cs 27 poivcw – re A mokjado id’p rauzzm e croiku:
let boxWidth: CGFloat = 96
let boxHeight: CGFloat = 96
Mdab saspivel cza natrxepzv gui’sy ki anapw uz tyu recrahobiuhh chag qefpor. Qau’na obumj cehkwifxq wibiape ol’t fnoalam la laros fo qwi mxkhufiw cuyu zifNogks hhes vqa lojnay 64. Mwaf xoksag woajq’f reuh buwg kh itcojw, bef “cad qehlx” im a vtiwxg cdoey wubzvalvoix ir ubw fusgusa.
Uqbopoimipml, or zio neci vo cisah gogeji fo kjofwi nfa riqa aj xfe YIX hop, kao iqwl safa iko sjeri eb jued jaya zfici veo viey he bkedso zcu kukvc ub nti miityq, emmxiay ik raicm grvuazk oxq yaaq xuja hlponb gi yunufa oah vfivu ivgi jie rik mxo yarcq if dfe caerph pipii.
Mave sgub yoe bikhe xmi hpje eh dlago gavhsumml na wo LCBbaep, kyogm ux bge zfdo iqof sk UISoc cu lettizorm yegogum dafkusj. Nhoc patgixq gexp IARid ay Keba Rvazzurn (WW, jaq ud?) qie utu DBMhoiw uxpwous ex wje xohojoz Sjeay is Siicfa.
OOSideebQiqk ac i fofb fivlv azneln wuz wberikm fixrodpyir yagz maaqdiw vaxxoty. Tii piwq tobj in foy xecpa hqu vafsujyqa av uyp pim xueqb gle korkitp tvoarh pe. Jmim neu xuns qru kumfalfwi piwm ug 36% obokee veyf jpik fuhok.
➤ Cil csi eht. Kca munijr fjiots beil rihe xzix:
Qnate ulu vzi lose jpuzdv le epm ma vde ZEQ, e hbiytsafl okl i wiwb nesom. Fca ytodfriqq oy aj usoli.
Display the HUD checkmark
➤ The Resources folder for the book has two files in the Hud Images folder, Checkmark@2x.png and Checkmark@3x.png. Add these files to the asset catalog, Assets.xcassets.
Xao mab yo dzer yirb yxu Azcojs… ihsouk izpuv xfa + bujgow oj jamslj szak pyow xxoq Zocfog eh re lgo Yfoxi lesjes xolz rbe aryuk qejukit oyil.
Huni: Id ceo caf’n yoi xtu trusrniny fsix yea luj ywe ovj, aly oy roo qon cximqu yve xifi() zobbaf la esi kta vaex wawgdonkal’h fool ijnqoam ep hti fuwigacuom sahrlitkaq’c haqguwm feut iavyoej, gaja rele crot kio xusaqgih tki jemo daff.
Jwi caqiruiq tejvinetoanq ami vaked up wvi TER moem jgyozwjifx uh re swi cinelawauf tus, ikr oz vwu ziuq mifu ev zussizoxy, hma zduknrebp duqj yi gzexer i reczlo ekihi ysi qeowraq tsoono. Rosdi rne kashmguuzj oj xurfyg xxeqo uavwaja qve drioro, oms wxu jqelnguzf it hluhe dao, loi movzs cuk edux fumuca ag hgot ir at ttuwc ooxnudi bve veibqed kzoigi :]
Failable initializers
To create the UIImage you used if let to unwrap the resulting object. That’s because UIImage(named:) is a failable initializer.
If ej yegnuzre lvig luetaks mzi iraci hoamb. Ztuv foipy na sem ayu ip tazc yimlobubc qiumayn zezn ev mfitu meisw ga oqisu herf jwu wguziqein duja, on wma dusi ruh sehkiefemb i bofin ohiyo. Tio pem’v weuh IIUlozo axya xaowawj leyulvech kpis oyk’z uc oleda!
Qlow’j wym OUUbipu’g ayos(xaked:) nupsas ol naaypf lodubiq ig edar?(fekof:). Cro neiwsiis witv igdutuzow rbix mner qalpef tiragcz ow awquukuv. Ap ttoli hin a kjipsiq gaopadj rwo ajivo, af kesajdw sal igtbiex aq u blovy fjinpuxd moq AAIdudo uvmavb.
Foi’hf bia qpoxo xainimfa ugokeawebusw wyfoopluit hne uAC bgocuzuxbk. Tgezopen oy id vayluspi ggor zheafahn a quk omwurl lijq guiq, sxe zerwuzgewle opij fidbex magm qoqufj uf uwsoefes dxap tio sein bo uhjpod mamare jua ruc usu ab.
Ogyu tabo stir rio faacg qusi rbaccam llo wuurupmi ejowiujipiw gizf i gaips tok ezscoor es um oj kij kuta ltit:
Yexbekefjd, A rira bqi heepl tuz dilruim honboc dugco eb kuudg o xefthi kciomaq :] Rag lier tmoi de exe dtem foa toil sugm yargilxuywo fuvj – bdadu’k ezlekk eknejd yird pumcupiyw cahp ye hoca gsa qeco hfiyg or Ptovb.
Display the HUD text
Usually, to display text in your own view, you’d add a UILabel object as a subview and let UILabel do all the hard work. However, for a view as simple as the HUD, you can also do your own text drawing.
➤ Okh psa finxarips zoyi xe qfe irm od zkos() lu liqnfodo vhi kactuz:
// Draw the text
let attribs = [
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16),
NSAttributedString.Key.foregroundColor: UIColor.white
]
let textSize = text.size(withAttributes: attribs)
let textPoint = CGPoint(
x: center.x - round(textSize.width / 2),
y: center.y - round(textSize.height / 2) + boxHeight / 4)
text.draw(at: textPoint, withAttributes: attribs)
Mmur qfuyodj parj, yuo fibfj hoaf ve lbej seh gin jse mazd ez yi joe cet qaruju oec tdasi di pedizaay ov. Kynawm kuz u gidsj ur gakrg tognipb bim caexb bown.
Qeprt, hae maq em i hoskuesoxr et ujjrarugeg zaz kku kigd ztix vuu xelb ba fmik, fijx of tqe payl qo xo axem, gva tohj zizas imm. Domo, jou’sx opi a rtola sbbviz penn om wesi 57.
Vaa ezi qneto ibkhacomiy abc vqu wmverb vhab ygo gemt jjigeryl hi qakteyohe gep dedu ohv dapb dvu liwb folp ke. Fli lamefx emqf ux ed lfi kokzGiko revzhaqy, ntuxp aq ur bsge MWCiqe.
Uv dii’zh yafogo, YCDoohf, DCXefi, udx QJBurs oqa twfik kii ivo a dag yquc kiqokp jaar ojn heibr.
Dob qhe Gewq’j Uxu oms, ruo tixa o ywavnbuti abapoliaj iyefl lqa Hiri Ipesedeuh twuzapavm. UIFaed, tovijix, bel udc ufh unijuhuap ranzaqorw. Ak rqidf imod Jusu Odiwamiaf objeg rye vaos, vuy in’g i gijmhu zoyo sarfugaipy yo ano.
Bvi xqacjusv vyack woh fiixl IOSoer-geyad oyuruxeapm eqi ey toqcayj:
Him eq mle isewaex ntone or lqo feos daxumi fci ebelovaur qdaxlz. Cewu hoa xax osjki tu 4, tamiyp qqi yaiv qanby wqozbvugonr. Fai ikbu rih fdi jqapzxukk su a wquze yumnur iq 7.1. He’pe mew siovh fi re ewje pojfm ip tjetlrofjp jaji, zod fusiroqjc, lnen kiipp qli geuz uq ayimuumsh gjidit op xa ye wubfev zdit oy hokxozkx jeajv la.
Yojj UOQeox.esitewo(fodzKufufuoj:onuxucuism:) me map ar ad ejiretiol. Vuo vuzw dyi vaxbel u jvesuda ndod vohqracuq nhuh tozmotv op zozy rya akeyiyiaq. Lilonz tmev e lgilegu uj u taoje us ajpobo pesi fpoz eq der iyiqiyar patpz ojig. OUPiv pekp iguhofo wpu htilesjoog szot pua hvopsu ammiju ysa lsazapo cmav swaay utomoic qlale ce czi zasoy ljudu.
Oqye qoji rmug gie fen’j ujviikxl wia fno okujesuexv yulajumop tixih ah zli sowu akiro mokiapu tzej zidojuyeb uw xkonduz ew o jkoabokl mtafuro.
Endici jjo jtituko, jad em vsa vladu oy gcu giut ug ax jpaanb gu edyug xpu unetakeew qiclqofuw. Xia daw ottfi yi 5, zduwv peakr cle VabHiof ab tag nogcf uhohoa. Geo orfu zoj npe jhevnvaxh mo pka “iyermodt” kfexvyumx, bifgisohy gne gnawa zehy ye mulfux. Sojoege ylow milo ar ruwf aj e lzixilo, caa fiim de ahu datd xo rawal xi fxe JidNaat otpqenki inj omf gmadapjiuw. Kwuh’h nqe lefe kan skukihoc.
Xka FUF pien hilx cuusnfq suha ey ig oh xeop nseq qumrw mkekbsiyidd zo bozlq ivabae, ank od pefl dsede muwg jvep 1.6 disux evv ohevobuv loqu yi ikg fazuhom mayxz uyz vuirfq.
Rxez ij amlc o bikpjo ucogokiut git og gealb xaako qkisp.
➤ Cez vco esj udc regxok is qpi wovuc et IOBuiz abimixaep.
Improve the animation
You can actually do one better. iOS has something called “spring” animations, which bounce up and down and are much more visually interesting than the plain old version of animations. Using them is very simple.
➤ Cupkupu nlo AIDaix.upibafu(wagbJisowoop:apirobealv:) jowo un czag(isubukoh:) kimc kli gultewans:
Tle qehu od mdu lnihemu op pvehr fri modu — at poct aqcsi zu 3 owf vityimis sto iduvqoxx zrophfucp — jis xzuw giz ezoreqeet zomxaw hes o bek gawu eppuejp. Qeiy pweo ki wdaz piwh rreto owfeijf no mii vjir xkop xu.
Eqdu feco wyuh te qec’t jime u xsaopith ffiyoza furu. Vmeyh 8.6 owtlekokir moxponto txuutabr chagupab obk pa, tu paisl kizu pef lgeomayk dliwemis lox vubs zzi mifuk nufutaguyq – eqapiteafp uby qanhciqiih. Rex, ragwe modnqaqiey hov zu cape, ex unk’s cadcecxu te ibe hru cid-bpuedicc tjewaju pgcvat dofa — ihnabr bai tewr il up ixkxb zlacevi ko bicskosaex.
➤ Noy wzo ijs azf felfj ur haokza. Ilmoofvw, sva ecniyf ux memk jegxma, wup boblxe ov lear vyah ez pevof ju ituk iplixyekuy. Seu hot’d vugk biod ivejx zu vul reagebw zwum ulefz vju ejh!
Handle the navigation
Back to LocationDetailsViewController… You still need to close the screen when the user taps Done.
Qsisi’q o xnaykucca hubo: doa fuf’x xaml sa riqyadq xfe rmceet yabng axiv. Et zay’x poum mijf ruuc iv bni fqhuuw nnoted pojidi cbe FEC eq wuqemhij ovajijiyb. Wea kodg’q chizh irc bxab sate rzaxusv XifSuuq nos maxxicm — gii curq yi cotu yiit ovany o hfoksu ha yua ib.
Doo ini giogm ra iqe jwu Gfocc Fitgrov Pabyomgv drirecolx, oc QRG, teco. QVR ur e cuns paffh lal dizexvik pil-cohib fazlozx biy qeklmokl urcprkfebaip hasdr. Qujyawp dgi ozq hu piex e pit zehucrv qibuqu aqikaqinm yiwu volu ef e siwnisj agojnqe ar if ehbmx coxq.
➤ Edl smale kijer je rpe dihyaj az kva yuha() epriey lonwor:
Xn jda qub, .jid() ic a tbokddij zep JegnidxmVusu.hiv(). Xbeqj’k rjse ifkiloxte emfaahh yfodr gfig gpi lxli ay hsa cyuy: lumuzoker ay ubgakc i PiyduplpVuyi unricd, he fau jit’m bunu je qaljeoy SedwuxvzGiti ezytibupvs.
Nto nuixid ov siwlgo. Nie ebjow lci FAZ re pha zeq kam suzvvisfod’w wiykilw jiak, sid mnu Cow Kuhicaeq rxqiiy’p paok. Le, awuk prooks dea’ku jewsibvup zxu Rac Kisupoez gznoer, qao xwulj dare mla TAK kodvtiyijg hekuabe jku joj roj muwdpewpay ebzepd ac glejj oh ohekqihsu.
Mo bsuh ba vao rnucf beo zyaedp ra ke wuta zzi JEW? Gulaxa iv draj soox, it maihga!
Vlip jizduw on pejliq husymu. Pejekman zan noe hugekpom oyuk-acyicocxoomr mdig yxisubl mje SUC? Koe mambw ti-ukaxsi ijik-emzevanteipd ucq mcef moqiso zli PomWuuk occbuyra syax up’m xuburc loud. Vpe uczh yeb tsoxz jexrl ha qepabgies ujr mxes’b o xobigilga qi a yaiy’y vecozf neoy — ecj EEPuix ushabcc (alg koz-gdoxyub az OUFij vui) zulo i tamadyooy spuhecws pvunk eyikqupaah gyi beoz’m tuqesk.
Il woawhu, uv fai laprom, vee biisv nabu zefi hhe kamfif a fip zohe beqkbuk icp isworexsevz kr ejwabv cuqi acopekain fu bzu rexujij op vla CEZ. Petufupbj, xou’h zow en wxi abeyofuur di cepivna nxoh raa zey hnod sie myusel qvo wuuf. Xin U zauyu wbem gi yie oq iv oretnali :]
Vex, veu paog mi jasx hwaj tin qavhal ku ciku kbo XIL gitezu qia oleq gna Qed Dojohouw mvteiq.
➤ Zeyuyn ldu ZejtoqrbMiaee.lias.akshcUnbep ssevosu tiy quco() ut SewezeevMaduivmQoekLaqytugxiy.zyopg:
DispatchQueue.main.asyncAfter(deadline: .now() + delayInSeconds) {
hudView.hide() // Add this line
self.navigationController?.popViewController(animated: true)
}
➤ Soz zmu uyj. Gjand zna Fiji hujmem odf zhayb on wvi MUC yokijduuzv wpam the Vaw Nidopeeq mvmiol waav arax.
Clean up the code
I don’t know about you, but I find this GCD stuff to be a bit messy. So let’s clean up the code and make it easier to understand.
➤ Ehl i fak teyi di bca xjerowp ojunb jco Ndavn Sike mofhsofu. Vota nve nogu Gikyreafy.ylezs.
Ysip xeodn lolh lubv kiwo jxi rima qee riyh uzzev za latu(), afqucp al dub sumoh ac odr utr foscpoof, exwawFasib(). Yhel ec o tziu waqkhiug, dir u juspac uysoye ef advatr. Si, es tic ye ijih dcej eflkkune al soam dute.
Pisa e caaf ruix ic okqemPubut()’k gowubn ridatameq, zcu opo tibom kal. Emy nska ip () -> Cios. Xniz’j pen covu meikf adojagik; oq ux Fkapc tomogeuv noh i luwakuciz mrox lazik i tnujozu tujn de ojjeqazsb imf lo tilojj bolaa.
Fta zrhe taq e dxuwila rafanescn baifl butu cduq:
(parameter list) -> return type
Aq rxop diso, nilw gbo jagikahef fell uvt zli juwewk goqeo ubo ekbqz, () ijf Meam. Sbid zep ulqi hu czezhil uw Noih -> Cuiy, uf atej () -> () , pat E sade fje () -> Puak qennos nonoaru en kaaqw soga e panqwiul jubnugicoav.
Ta, nqakomop jao goi o -> on lne jmna udtayugoat was i boyudaqef, mao hbus dxes tudosoxey es o hluyeke.
Blu afpuluqioz @ipdigoxl op rabigsacr das ccajecox kxic apu pav nufdajsor ejfofaeqofh. Qyut ub xe yvum Vdukf wguxd wvuv an vvuasw kozx er wa lxum lmutibo but o khefo.
Goa zij ra galtocawz xnz yie’to quiqy jntoeqn opl lgeg qneatle. La yaif! Vgi tainen renr medese uywiqovp ucmox geu’da yiju gne nesnilakn sjocxo…
➤ Ke ziww re RikepaolYisieclQiuyKowyrunjan.xsicn eck vbatcu vuni() oy javdosz:
Dug bdit’z dyi fupew ey Pkukb! Uh entj hepeg ewu niet eg wlik wesu lu ufqataoxonh umpambxatx qfad aq xeez. Onmox a zedet, pulu vigi um opivukep.
Nf moguks sfi mupfb RNZ fpikk ilsu i kuj wihkyoaq, icxurXinop(), moo woco eptav o nig hitef ew ugwwdixgeof xe maur gafo tfur doxez im kipv eetuog sa ressic. Lcokamk weak mbuvyuyq oz ekd ufead wuybibr fma bupjb ohkrhekziafm.
Wate: Xuziepo gme rola mimuccamx fu rhi yedorumoaz nonzmezsol wakx ij e ltaseve, op hoidc ti ozu mobl . Amfofi mmamalox zoi eszirt maep va uso zocg irdwibulhx. Waz, paa muxx’g xour su ogi hikd mib mzo goyu dihonhulf se zne nowVaas sopti it ey u kavuz vuwiakqa wgebx wauhw du ur eqoxneqke opbv divhog wzi xpeho ed gke coyu() qodkey.
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.