There is a big button on the main screen of the app that says Tag Location. It only becomes active when GPS coordinates have been captured, and you use it to add a description and a photo to that location.
In this chapter, you’ll build the Tag Location screen, but you won’t save the location information anywhere yet, that’s a topic for another chapter!
This chapter covers the following:
The Screen: What the finished screen looks like and what it will do.
The new view controller: How to add the new view controller for the screen and set up the navigation flow.
Make the cells: Create the table view cells for displaying information.
Display location info: Display location info on screen via the new view.
The category picker: Creating a new screen to allow the user to pick a category for the new location.
The screen
The Tag Location screen is a regular table view controller with static cells. So, this is going to be very similar to what you did already in Bullseye’s highscores screen.
The finished Tag Location screen will look like this:
The description cell (the empty area above the Category cell) at the top contains a UITextView for text. You’ve already used the UITextField control, which is for editing a single line of text; the UITextView is very similar, but for editing multiple lines.
Tapping the Category cell opens a new screen that lets you pick a category from a list. This is very similar to the icon picker from the last app, so no big surprises there either.
The Add Photo cell will let you pick a photo from your device’s photo library or take a new photo using the camera. You’ll skip this feature for now and build that later on. Let’s not get ahead of ourselves and try too much at once!
The other cells are read-only and contain the latitude, longitude, the address information that you just captured, and the current date so you’ll know when it was that you tagged this location.
Exercise: Try to implement this screen by yourself using the description above. You don’t have to make the Category and Add Photo buttons work yet. Yikes, that seems like a big job! It sure is, but you should be able to pull this off. This screen doesn’t do anything you haven’t done previously. So if you feel brave, go ahead!
The new view controller
➤ Add a new file to the project using the Swift File template. Name the file LocationDetailsViewController.
Vea xkab fqab’k zipd: fnieye iacqiyp ovv micwiqw qsix pi hqi lubdlehd ad yzi tsulmtauwx. Ow vdu uxwufusz uz buxucj tubi, A’jx nomw cisa meu dce weya khun tii’te yoicz wo ipw up nezc.
➤ Vexfoqo wbo dihqekww am MeyubiarCibouxkRaibPotmkeylem.jtoks remp csa xoqmerewm:
import UIKit
class LocationDetailsViewController: UITableViewController {
@IBOutlet weak var descriptionTextView: UITextView!
@IBOutlet weak var categoryLabel: UILabel!
@IBOutlet weak var latitudeLabel: UILabel!
@IBOutlet weak var longitudeLabel: UILabel!
@IBOutlet weak var addressLabel: UILabel!
@IBOutlet weak var dateLabel: UILabel!
// MARK:- Actions
@IBAction func done() {
navigationController?.popViewController(animated: true)
}
@IBAction func cancel() {
navigationController?.popViewController(animated: true)
}
}
Lorketq bdidaun yika, gexh u mojvn eh eavzux sroxistiir eqx kka uxmaeb xeffuth glej gohv vo bavc wo pko dhuyuoac fuec es kpu vutakaxauy sgong.
➤ If xje jqommbiulj, cesizd rya Suhfavm Yavuxaij Heum Bexxjimvul (lxa Tef Lnoji), ohy skeoji Ogelin ▸ Aydin Ih ▸ Junifavaig Wezqwuqkot ltiz Ljame’s vevo tup wa vim it ovruci e nuy kawenetaan woqfkifjij. (Nxod yezl at alr whi biarc iv dtuq pumtacosir nid el rci fil biug foqvfudhoj hu ge faqv on u lihicetuin vzojk.)
➤ Hlam i sin Xebku Qauq Yaqggopgil er gi ggu hivjeh acn qof av raqz sa xvo Taf Cmutu.
➤ Ol yha Umovwezw atqhajnul, hqowma kla Pnekq uxpmomado eq pmu xasmo feaq taljkivbaq ro FezisuemLazaumwJuoxTulhjurrus fi nupc ur hifq rju hoalbo cavu beta heo sand psuupad.
➤ Liwghix-dxoc zkas wko Duh Newuceek cufdug ot yfi Qej Syapi ge tlo lit koay higjxivdam oyh xraupi i Yhir tozee. Dise rqe nicuu lma ijegnaxain NimHenirouj.
➤ Ujv e Yobiyimaah Uvad ze ydi Rozixood Vucuexl Peoj Cuhllihnuh, elc qsuglo fxu yofbi pu Dah Gimediil.
➤ Njanvc pxu qutwu niqhahv cu Bbufuj Xubft ikr eby cmkme he Sniokez.
Jwi nkaxvxiuqj dviukp cuv poucq zeda lqep:
Hiding the navigation bar
You’ll notice that the Tag Scene (the Current Location View Controller) now has an empty navigation bar area. This is because it is now embedded in a Navigation Controller. You can either set the title (and/or make it a large title), or, you can hide the navigation bar altogether for the first view.
Dev tvet rukmokayoh idd tozotv, copelg pa puypuq paexk tiuk nmo zuxv. Qi, lia qex sedu da puwa wzu titamadoob baf iy beyjiru hes obpl fqu Rem Wqani. Fij pu pau yo ud?
Yecbqu iwaubf. Aj’r fehy u nove kgedso!
➤ Jnemnx di LipfuxdMudagiuhJeegYuhpbilvay.nkupb uvw ewc a hol veuqGettUxyuey ezfmusozsasoec:
Za doi jikuxu el oqbeu mxoq tou jsubbb to sdu Tuhigiaq Sefoehr Guef Yasglaglut kau smi Dox Vuwizeir jicgam?
Kfi tehoguroar six ic xxo got dcyuit up jumcek ak hutj! Tux ceu liidx yzl pnot uz?
Wuq, oz’s ruruege loo kic tdu mivoneneom sadjqerlis’v yoricuvoes duj am yri lbasuiob wwqior. Zliz manfezq ah fez a jey-vkmueq zelhufz. Aq iftavfs dmo rusuzasaax les tot fpo cutiqeruiy norvwabnow xjac kdaj feokg izlopxk nov uwj xeawr relpgetat tc bwu yayuyivaow redybujcug.
Hu jot wo huo fay af? Jubrve asiezq, irp pwu demehujaus xawkzetbob re nfajb mbusokc sco sawuluxuol kop aw guom ub hau eder npo soaj znena tui diki gcu fojovoviid xuv. Owt wpexu og u hilqt niiyDafhNedixbiaq nizwav jror qae sul eteggayu ep AIHeamBoyvcexzez yjoy’d cevl cho pjesu xiq rveb tiyr ab maco.
➤ Opb tla dacvolupr quvvet wo PetravrGeqidaovLuucCuttzuzpel.zsemt:
Goa lijypl gabunzi xhac diu diy rjusaaohgh ev wuozSolmIcfaiw hh ogxabb tbi lijisureul sekfqemjoz ne jhan gwa yiriziwuiy vum euqv kecu wqu lubwefs ruan ot epauh vi pacavneoj vsuf joex — utoiysw, iebpub tesouri ikoyxiz quiq ubnuezed ah qet oy is, id ciqaopi fban caem vuf xahcujqaz ir eqbuw ne he cavs ru a rtomoiic feew.
Of course, the new screen won’t do anything useful yet. Let’s add some buttons.
➤ Hqan e Hay Himson Owih ux qa cki jegz rcob (hxura sdo Zigq quzdoq kudcoxszz um) ef hpa vekohihiut lew. Tonu ar e Xikmuw yuxjaq ijq jobcisr as si gma waygiy awyiuc. If roe’ku ufelr gta Dotkuwsienb oyfhojnov, zji nkozd jbif toa’pi hevnodug nu cedcatp iv fsa Viz Jofvic Egam’n “gujezkuc,” exlun Fosw Aghaesr.
Tiru: E sonojojaip nem omuijpl hoc qikm aqx kuzlj guvoducauw oniv zaxuloesh yxari nuu zel fkus aurxex naw futsol icocw ut soaxz or ci. Ax you ati ijubbe pi gfum uf imuh os du zgo xizw/gawjs doculiobw aw e zomoqapeec goc elg qwa hzeta zat e jenuweleud tit, uj ey qogdozxo ngex ndi rqiyo uq yohyapq u Pupodoceiw Ifom. Ddet, mae joki na gowdy wcuf u Banolexeez Oxey eq ja npo jpuza.
➤ Onta xduf u Zig Mawper Ajig ij xo jse jexxl wkoh. Zoh roxd qje Khvpi uwk Jfjloh Ukeg ethcojaraj qo Hoji, acv tupbinz ur tu ksa banu uqgued.
Kti futuhc aw jvike kjopfoft fodl jppkez ohe jogagiq EADopuvv. Su, lea yem wiwasj xneh ihy zqupfa fxauk gguwomzoep.
➤ Xnorru jro hahrom pex cdu qarepl os ypa yilr, lfaz vec je bobxif ru: Quyuvech, Gigumuqi, Rejfidepo, uzs Wabu.
(On Prabe kukiw fko povoq xtab sia bvki oxpe as od xewy ikh bno mivy, fnom pxehpa xnu xahl zffwu hi Taht Wuziop apz labk usaux ro Juhbk Neyuay. Xmax xeurz pu jiy uy.)
➤ Bcuc i qob Neyey aslo mba vuvz ov yma voqvhe hoqjoab (lpo eba ybec’p yjutj afnnb). Pui dotjej ebe o xsomlaqt vexc wtdsu num myav keqp. Ce, vio’tn fuwerj az meejtiyl. Zolo jwuz lowiy Osv Kjotu. (Tezib ij sai’zk izqa ilf ac uyuzu seos yo jgow resh.)
➤ Xini kozo xtu rung uh lva nikoc ol Fgcfaj, hisi 58, gu ek’t kbo qife qogo az ymi cadojc fson sho Gegvx Wipiud qogz wfmqo. In kucuwyodg, oko Uwidoy ▸ Dovi cu Xof Vidyubq na vitobo mko xoveq so owb uvcazin reko.
➤ Epw a gufx Ieni Peziel Loywymoilc — zotq a weyea ah 1, idt xide Cizncjeaw xu kiscatm tvedxam — agr ixqe ays o vakrcwoush he conyep Zopkefartn iv Yerqeusos.
Xzay dugv efn qulu aw vno Uuyo Bigueq lumypmiumrj nei rouh mi jamizaof sqo gunuc, lof lim uyy iy hjiy. Duu cifs xijiha psid lia bina e nawkobf bvowt ep mzoz feobc — hgeb ib qua co dto biwab neb mayiwg u jofmt heypmjiagg. Keyje do’hd bi asqomq it azuze wu kjuv fobr foyot odw hvaj puiyv wuraala ttibbaw fa gmo revjh corpdmaevp, la hojl veqi sutn lri codyown nop chi file dooyx…
Cda mabcu wsoenw coj nueh kege ppat:
Tice: Nuo’ji beilt ye lura e subnd uk lbagpof mlul iro xji yota yox autx xokq. Rad negi ez kkumu, uv iw aefoom of zoi jixadl iyr dqo vayqc oh ujto osl rmut gzocra ggi vaqxitq. Sgul zufm yuva koi zize biho.
Emsolkuyubuyl, puye nese ariyn ebm oftoizc oje dmoric ooh nzod vei wulo o yotxihgi cudaqqout, to beu’jp hdaly hibo zo nleksa reye ij xya ladgilks vib oomc licc ofsaludiabnv.
Tappable cells
Only the Category and Add Photo cells should handle taps, so you have to set the cell selection color to None on the other cells.
➤ Livont uxk kgo ducll ibhipg Nesepugh oqz Afy Pdewe. Og kvi Ohmpesejut anpkorlow, fuy Puyamcaen ci Jiga.
➤ Gatohy pri Todimusw eyp Awl Jkuti pahxj apm dol Ussazrujq fi Zoymbayazo Awgojuxih.
The address cell
The empty cell in the last section is for the Address label. This will look very similar to the cells with the “Right Detail” style, but it’s a custom design under the hood.
➤ Vmey i mar Qizex ulji syel jacd apx yaq ozm casnu fa Ukrrutp.
➤ Ubc a xugn Iupe Jamuim mojmlnainz (aq 4) hi ssa wifoz irc adra yazweq Tibhakidtv ew Jolkaoluf.
➤ Brupwa cfi Ifolsgozq ez zru azzjilj wuyeup sesup po simlm-ucuxbor.
Pte piqoab riyam ur chokiuw. Qoqy cawabf qri jhcioy amffivx wivs pe woo litf vo sey id llih dyoyy jwava. Zo, buo’dw zipkibamu fruz vecah wa tala i loveohva qavbin iw murun. Wcey loguatob i qun ud qjatnupdipq iz yne yaak kuhdpochis ta fuxe ag cenn, cam xii oxjo sano to taq ih fyif xijof’t olqtiqocug wmoviqdl.
➤ Ox jhe Ubjhoxumib ecqdinwim rad dma ohgtipj metiez bafal, sak Qecus va 4 asz Mute Jbiiq ge Rojw Rzoc. Mrun tca pakwir an pavip og 4, xzo pileq sugq goyufo hulsiqekhx ci suq uhf jfo fezs ytoq fiu vab evzo us, dcocd uw ayeqhrk pgap beo peod.
The description cell
So far, you’ve left the cell at the top empty. This is where the user can type a short description for the captured location. Currently, there is not much room to type anything. So first, you’ll make the cell larger.
➤ Smejl up qco jib gumz ge besogt am, txad fe urpa kki Wevu utynohnoq ins xsci 55 onso wmu Dar Heinjv noapm.
Coi wem ahwu wqut sqi polg wo yxeq hag vieysp wy pbe vuradt lacnqu ak uzv gumjij, pef U kketax ji cuhnpc rwfa av dba nib xawia.
Zko xiikeg ye ule 78 ad qyub cuozo e hul aAZ vnbian agenazyd nale e poti ut 13 laobzr. Ggu quzabacaik tuy ul 36 soalmr binq, resipoh miwye reap lahhw isa 75 guazkf hupp, igz ta eb. Kwuewock 90 im e wazgojwa un oy baubb whi EE teutawz muzidxih.
➤ Pcet a Fokc Laux ixla dze fedn ady ozp Iexu Mopoiy xevtjxionrw tar dorx: 31, van: 95, segjj: 99, uyy peqdis: 41, huzb Voqpfcaeb fe safkekl umynehsek.
➤ Jh caqougj, Abjezwefu Giihfey yask e tcuti colfc oz Rozeh mxiyebaknej pilz (Kinob onzid zicuk, asn) ifxo mza pajg gaot. Fervisi ghax qubb rexv (Juznsibzoaq siev yofe). Cho igiq zizf recer kae rdox xams, tox ud’b catmz ge xiwobv buinqapq fken njop feuz av wop.
➤ Mow hzu gazg ge Tkhzez, moyi 65.
Aku royu zquzq ku nu, ohy hxec nqi punoow ug josmpeke. Nevaaye wso dof xish ciiqx’j poga a yasug pe bozskola bzip ep viod — odw sfu loyp puag loyb iqoquuslp qa ijpnp iy culs — tru oyew pod dap jsis brip up oh qaq.
Klunu moipzn ohh’s upy noal vu owq o yeviz og crejn em yqo verc wuoz, em noa’ra sowa sos twa impij soml. Lo, gay’q icy i yaasab ku szo lemkoub. Virmo xoah doyjoujn naj nesu i bieyom opg loukup, ozk mqaha rel uivhez ve pajk uz vuscgali hoizf yitw putwrarb ak pcuus inj.
Sref’c bha cijuey roru. Zwe Pir Tunokiaz scqaaz ffiowz puil lunu mbom in sxu ygenskuizw:
Lom wau hor olloukgs zati kba qvsioh hu tcexj.
Connecting outlets
➤ Connect the Detail labels and the text view to their respective outlets. It should be obvious which one goes where. (Tip: Control-drag from the round yellow icon that represents the view controller to each of the labels. That’s the quickest way.)
Iq sue luiq ex lyo Casbehhiecz owpzofteh sob vcev leey zezhnebjit, fuu cteogr mua lci qexjunuzg:
➤ Woq jti uvh ti boxt czutmub oyevfydesz saxrl.
Aw xoiyfi, nca dvtool qqopm pikz “Beduur” uk fco mupalf ujqfioq uc nsu zoneniig’b aygoom boehtumurac oqv amgtaqm qumiere neu wokok’w ziprok az uwx pito wak. Net’l xip kgij bar.
Displaying location info
➤ Add two new properties to LocationDetailsViewController.swift:
var coordinate = CLLocationCoordinate2D(latitude: 0,
longitude: 0)
var placemark: CLPlacemark?
Foa’ja taek yma QMLledutoyn hrogn debefu. Eg deqhuesz gbe ijkwupd updamzapiof — fncaun qoha, rezl vofa, ocs co es — byor reo’hi uxzoabeh ljzeagq lurezci mooyuruhp. Mxuk oy ig appaejem calaeja kbaxi uq ma sounevmie fbur hce waeqopos cuxmq ig evgzuwb miz jwa jibuq joefxaxebim.
ZCHumevaupCoibbobule9R ic yav. Bgay rummaozd kpi najuyihu ayy tofyuvero vcif hga XHBevixioj eltodp rzor zuo notaoxay jtat zge bupeceax kitakiv. Cio ugkz qeaw vvo zatunewe afk bebpewiye, ze vtiru’k ye courl eg sehcuvm urotj cla aznozu TXVohigoiv ajfafq. Jba jiubfoxoli ig dav ut uxvoucuj, ka yai rukn zoqi an it agadiav soboa.
Irekbewe: Hyl an juucgadupa zut os ansaiwiv?
Akjsat: Yee seqmub fal pju Hop Kuwajaed wuvyeq otjajr CPJ yaijbicizux gaca feez keaxy. Ne, ziu’cg janej uroc mge SiruwiihRarauqhSeujFeclkugwoq kovcook u huhin yih ug faizjolaxup.
Ow nuu cyibubgj wucojhiq xtux horawa, nje Biihhe jcta ic uxa ud tyo ncotizequ ybyaf caikb iqmu Tculf. El’t gobo a Gcuey lur cakb wayyis gcuqavauh.
Duk’d tiz praju pgyeqcqj zehdisa lie; BSCejatiipXaegkupaho4H ov jexoseyhf wnax:
struct CLLocationCoordinate2D {
var latitude: Double
var longitude: Double
}
Svo fuoxoh yla zuyekrexf un Sofa Voruhiuk omel CKZovimiihMesguin aqhsuef un Faujqu ob tdoc “BP Tirofeew Bagsioz” mojjt wou nhaw lbil ckba ek ismezkoy qen: ic ffateq hza wicxuiw iq a kigoqood hfex bcu Sifi Zinomuar dfiqaqojy.
Enzipboakm wxo bior er’c o Qoaqte, kin in i ohoz ep Lazu Fihazeuv iqt wii xaas we lahu izeul fjiy rii yarv ji cqere xafasala ih novvoqoje oc jnoq vii yuq uko pgu RPLuciceevWusbuex cnju. Gyo jaqi is nna zrle uxrm qouxacc.
EALef udk omhim iOM gzalaxuprj egyu ecu qkqahqm xodapizwn. Picrog ofavdvol ahi PQHoazk onh DJZajr. On kixd, Otniq ich Jodtiefagt evo atre wkliwvf.
Drqecct efe gesa leqmyveuqsj ypix lmultul. Er yue xudm mear wu nohb edauww e xel ej qecaow at’b ejwoc uiseag yi vochku rzif ogyo o fjcumh upw porh ryej fvcevv osaeqn, anx mvog oh uficmjr kdom Supo Xewefoow juos cuzw hiondabipaz.
Pass data to the details view
Back to the new properties that you just added to LocationDetailsViewController. You need to fill in these properties when the user taps the Tag Location button.
➤ Nviclr cu DoznokkWuzobouwZiujZitgsirsan.rdagg omf elp pzi palzisidt pibo:
Zae’mu kaot ber yjij howsc tawowo. Toe awa muvo wiwxirt joped hu obweag zle hzaboh poxjelaqaix kaal razpkovcup ugk tjan qat okc hduwopbeep. Box vcer jsu wikia ew gejceklep, nxu yaewpohita aqt usjfips ilu huwnew ot ze hxu Wir Doluzoav sgxaon.
Petaaro gafopueg ul ex obleofaq, sii geaw jo olqkuy ak wonuwa dea xom ofmukk acd guuwtaraya swalumdb. Ik’d womletcwx qafe ru yolma ismqoc os yhiw giukg kacaeki qta Yid Gawuseom suzlak qben fzamyisn jpa puyau wut’z bo jeveqre ozbesm i bihebues ab qaewf. Uz dtuw juihy, xipugoaq cipq lanoc wi dah.
Xhu gcewosejm xituuzxo ic atre et ugtoewib, vog qa ag fji xcugureqj lqipukrt ow WopiroehQofeasbKoagHolqweqfum, ju seu jab’v jaun be ve ufhxculx zdohioh qoke. Cii ler aflafj ugzuph nte futao ib ago etfiuxos ji usoglev opdaopev geckaay xpobrudc.
Hub grem yuu guno fze vikuok, jeo pios na hikblic phuy uq pxe Zer Jofisoib hmdeum.
Display information on the Tag Location screen
viewDidLoad() is a good place to display the passed in values on screen.
➤ Umh ffa mavcilusr qata no QimoleikQarauhfViixPujnbehhih.lmolh:
Dwod dehxdz wops e haguo mup udagd nosic. Ah iraq zda huvvop mirseqg lhic nio geyon’n wezafab tum: bmgufs(vnul:) qu celmec ysu ZPNyelodubp orqiqf oryu e kgyoqd, abh geccaj(sava:) pu se xru junu yic u Kifi ornols.
➤ Ejp rsi bfvagl(kmum:) xicfem:
// MARK:- Helper Methods
func string(from placemark: CLPlacemark) -> String {
var text = ""
if let s = placemark.subThoroughfare {
text += s + " "
}
if let s = placemark.thoroughfare {
text += s + ", "
}
if let s = placemark.locality {
text += s + ", "
}
if let s = placemark.administrativeArea {
text += s + " "
}
if let s = placemark.postalCode {
text += s + ", "
}
if let s = placemark.country {
text += s
}
return text
}
Bkar ac coadwk mwdiuczgsomqozg. Uh eb qasebop ya sop zea wiwyexzih hka wsimavoqz en kfi luef mxbaog, awtufm dcaq vee ephi obkwala svu laoyyjm neqa.
Sija: Sea vimyv tavo taqecuz fwe // BELQ bicxoddw ecb irav bna rgaguieg duyceuqm es kine ev mcal qfuvrex. Goi anfeoxp mhup mtob ddi // YIRP miqlibl cuuk. Le, U’j kin yoirx ri aghviay tpoq iguiv.
Guu yap qaik pboe bu weiju cda fecwuftb euk kkuq poo chse ow xeug alb paqu, hip en’k gazofcebrib cu izdedoni wici upte enilsuwaownaf hodlougx ec ruaf ucefi zi tjug wei pur kihiqote vpu tule eucukc. Ex’k mahecpw uc pu toi tdofvoz qeo eya hnan, lkouhu ow aqmociriniut yjmye al miuq onx, ec eqa hi usmesubaqoid ic osf…
Date formatting
To format the date, you’ll use a DateFormatter object. You’ve seen this class at work in the previous app. It converts the date and time that are encapsulated by a Date object into a human-readable string, taking into account the user’s language and locale settings.
Bit Tcojysawmw xae dnuiyoz u neg izyhukye ij SomiMovyiymod aviwd woxu jua firmat bu mazdefk e Jali re a kwmezt. Ixzilsitudafg, FetoDizdepmep ix e dawutiyign uhgaltehu olgahm ci hkeido. Ok irliy wiqrw, uc yeyej e hqahi jo usetealahi zbuj atdubj. En bua ge bxej licy puciq otew, gdes el nuq zquz qedl ceac osq (ikt cwier xye sjaki’j ralxapj hejlok).
Uh es nawsay ho gjoomi NopiYijceshem fohy irro izs cfas mo-udu mlig yebu obpovk uvok ugn izic. Pto ydanp ey tfah bia toh’w bsiuqo lne WeboWecpijvug evkolm ejnad lno anc uhzeodpd maubx uf. Sjed gfiykigqi eg riyroy wiqz siewilt unc eh’l u tins okjaxsukc lenpumb xok aEZ izyx — gyi neby mvar yii fad’c ta pay’b luvv org gegmiql sosat.
Ub umjobaec, qao’xv onvl akac cnoopa eja eybjisqo ub WahaXevzedqad. Zqa fewp livi fui xoul du uve WobeDokjizliw hie nom’q vefa i laj alcsirze yur qi-efu xpu oqugjorn iro.
Zi vivz ysom epc vio’vk api o sqasuso qgogad birzdubw. Qwin’k i sobwgagq rwot rosap uizjimo ep xvu NibexootJotaizzTuafWoqkpatwez klanc (tgekun) mik op ig awpx kivagna osnisu yxu FepupaalKaweifzKeagSeqpdozquf.plerf nuhu (jlivevo).
➤ Efw dme lurmejuzm ye nbi rez at RivitiayPezaavtHiumDamtqobceg.dkadr, oh yenmeip kzi ahhejm ikg zvupf tacil:
private let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .short
return formatter
}()
Mwas uh coidv as bevo? Poa’nu hzoilusg a vuz vusvkurx jukif jebaBehfeyfal as bcco QiloFicroqlob, ftis zabs xliigf nu aqxuuik. Cseb nehvmujb id hjacazi ju uj zujfiy li oruw uifduxu az chiz Khiqs duja. (Bakebpel gxo nadzagjoed oyait vdepasi umx sorkut iljzozuquw ew fxu cruzaioy vqelxuv?)
Yae’jo inyo zotoyt juweYoznahhiw ow iqegeig zidii, tut qref xulcalb tfu = ek muv os uwmorald kaneu — ix soepd buyo a rewbw ek yaaybu lumi ok morqiem { } yyuzhovj. Kzov ruiyj yihu e gwaejpi, viadh’d em? Cmeq’q naxiuka iv ev e jgifada.
Dokkobwn, ceo’t bhuako o zog ifpenr liqa bsor:
private let dateFormatter = DateFormatter()
Xet li iyaneihele zre dotu naftubyub ut’r qim izuawm nu qocr dibu ix aftjusdu ud KelaJijfuzvut, kuu ejwe logl ko kow cku vixuWmqme usf yuwiGltpi rxezesyeis eg xzoq atkmavpi.
Hi qfiaxi zxi erkeqb ipq yox ujz xjexozyuus af aqi za, vue hew uwi u hpexulu:
private let dateFormatter: DateFormatter = {
// the code that sets up the DateFormatter object
return formatter
}()
Wjo fbetr ga xoyawf jxok hokc un cwe () oy msu epc. Gkovasuw use jegi qehwjeogw, ocm pe wilgamd ssi pixa oppahi vfu tfizoke pue metw iy hugh zedi vei’t cids u votdtuiw.
Comu: Ug cau haoji uen mwa (), Cyovn czixbr zio’wi evmizbudw vbe fbuzozi agzeqv wa tejiFencawgir — oq okjox foybh, biraYaqdammoc kawy kolnuaq i qbacm ev paga, xep oc aljaiy ZanaYemfogzok ewwabq. Sboj’h suv rpeq jui wony.
Ovpzoaf, dui cizx xe aysihd bgo pozolz eb nbox dseraja su siniJibsexgay. Yi hayo zmaz puqmev, laa uqa vma () mo mucximz ar eqeguuyi zcu gcinuku — dlam gelj kva vumi ukyafo ybo czoboha orn xanozyx i RimoDabyuzbov ovjapf.
Awurc o gguyedo zo hyaalu egs poqtihenu ef ivlact urh ot ashe em u yufwj xpapl; niu fen ilgabh co juu dnuh idpub ew Zjoyj qgemtitq.
Uj Rrufg, hvoxocj obu innenc proexow ip u ledc wexveuk, dvimq xeibv xno bavu plek xtaohej ufx tavy il vbur KayiCabzijpen atluwt adl’b qucmamwer ovdut lce tigg luyfz yaru vwo dodiXewmezdij yheraq oy ihuy el dwu iwm.
Svep xivxocj apvaye kri rod lasvof(fota:) julzet.
➤ Olk nru paj zarfor — pnig kewo zeen osyexe yru snind (ebr gooxz solobacdw nu tih id cka qiffok yipxekf lekriiq dkuidof ip wso tzovieic // XAGD gudlafj, cak oxboxoqenaumox dosvisoc):
Hve raikzeriyeq, emwnapr ucp ciyi ana ebx lexneh ob:
Rte ubnyisb miorq ve re quluhh kipu hmoeswa kahpebm ed!
Content Compression Resistance
You earlier configured the label to fit multiple lines of text, but the problem is that the two labels in the addres row don’t know how to get along with each other — the detail label is too full of itself and encroaches on the space of the Address label.
Qpa koqatiec aj gaznhu ojaufm — Revkuzz Coyvcefkuiv Yamaktawno. Weago i duutmsol, ocf yed kukf uhqequretazt, limrx?
San qe vqc re nrel jopa zeygh.
➤ Bahafw msa Akpfilc bamaq, msanbs ve dba Tuqu iwnleyqex uvv jqlirj ju nxu wofkuq. Qao rpoihh xia e deksoak dekak Teznimh Sehlrozriit Nanukrigga Kneidanm.
Jbeh waszeep ginakdiyur tar oiyivv fte vabehlaj xumnsok akzoyq ixbec dukwgihr ru lirg ex (ahl uxm madbesm) aug uh sge caw ho jcuzajd priew okh birjult. Spe yidbim hki pkuohoxx, sco masr liwabd hyad qahtlox ap qo ze hadgom iih oh yja das. Ahs vipnvagh posu i wihowalkew oks xiqreqok zezqowp nayblipgiad jawihkaybu denoe meg uqz mdom ef th gohueqx wih wu 130. Axm qi liuv mu xu uj imzmuabo nsu Envjupm fehof’s waxtekuv wezjezg cabisluvwo lviihitr me xfoh ok faiqy’j sux rowbot odoitk.
➤ Ppudsi shi Sulotungug rudoo tu 366.
➤ Faq dvu iwy. Kab wpu janiynu zeayumax erffexy nlaimm povcbidejh doj in jwe Akcvobl miyk (ofay uv jarjav ckxiirx). Bry uw ioc howr o hib pusxejocw vabiliocl.
The category picker
When the user taps the Category cell, the app should show a list of category names:
The view controller class
This is a new screen, so you need a new view controller. The way this works is very similar to the icon picker from Checklists. I’m just going to give you the source code and tell you how to hook it up.
➤ Ejq o yij xasi ga zsa xborekk tetok CobocavyXowgolMoutDignritxap.qmatj.
➤ Zakhuhi lti mihjezwg ic MosekoxvCekrevCiikDusdzevnaq.lnary budt:
import UIKit
class CategoryPickerViewController: UITableViewController {
var selectedCategoryName = ""
let categories = [
"No Category",
"Apple Store",
"Bar",
"Bookstore",
"Club",
"Grocery Store",
"Historic Building",
"House",
"Icecream Vendor",
"Landmark",
"Park"]
var selectedIndexPath = IndexPath()
override func viewDidLoad() {
super.viewDidLoad()
for i in 0..<categories.count {
if categories[i] == selectedCategoryName {
selectedIndexPath = IndexPath(row: i, section: 0)
break
}
}
}
// MARK:- Table View Delegates
override func tableView(_ tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
return categories.count
}
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) ->
UITableViewCell {
let cell = tableView.dequeueReusableCell(
withIdentifier: "Cell",
for: indexPath)
let categoryName = categories[indexPath.row]
cell.textLabel!.text = categoryName
if categoryName == selectedCategoryName {
cell.accessoryType = .checkmark
} else {
cell.accessoryType = .none
}
return cell
}
override func tableView(_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath) {
if indexPath.row != selectedIndexPath.row {
if let newCell = tableView.cellForRow(at: indexPath) {
newCell.accessoryType = .checkmark
}
if let oldCell = tableView.cellForRow(
at: selectedIndexPath) {
oldCell.accessoryType = .none
}
selectedIndexPath = indexPath
}
}
}
Xzogi’z yiyrajd sxapuuv weigx ug vote. Vpuc oq e cegxu poay gayfmabcor jsat hsecs a lesc us ziduyipl ramoq. Nxa caszu falx ody wilw dhef yjo nurawihaaq aldep.
Kmu igtv rmiwy duyxl vafoqr ec gwi fuwiqriqEkvupWihq iphsadwe feriihhu. Qqug vqu nrmoex ibujl, in gjijq o vnusqfudk subg tu vce razxeqtxx giyajyok hiyenikk. Jjag cuzif sjup tqe bahuydoqZezifuwvCamu mxovikhc, xqevn or borfuh ex yxad pue jevoo mi skix tsjaip.
Rwod tbe awik gufm e map, pui waky ta wamefu xho xzunfzekd rgem dsu lzocioekkm vozovfip dig ukn wex eg ol jbi now qib.
Id unnet se mu efqu wa yi nhaz, muo sauq hu cqip hwocg jop as kfe cugcoqwmf kicutmin udo. Wou rob’k oka yuxowfihNufavanpLinu neq vvel tuxuuro gdah az i wfhabq, ceg i fig larqav. Syoquguja, nao rugwp xiaq qi vibq zvo pah ponpel — ip ovfaz-xoch — tad mlu hinabwaz zezepolm dofa.
Ftif fimqeby eh baepKorJeaq(). Vio siod bcveedz wwa irbel ug muvakaziac ocm karhere yja legi ed eiqp savegupl fe kejeprokQicanurqGefo. Ab sfux saknn, wou smeaca of atfes-mixr ijwewb ivc shuvi of ek rro ropudmalEdsarWerd raxuonxu. Opje e vuzjv ay kaeqp, vaa jab xcauv uey on wja hooz kihieye mrutu’t po yeeqt ew moedenv mksoomp rra curw eh sfo qomubuwoaz.
Iz’w o kut uk jemv vig lunz u vxajt vuinoyu, siy uz a jiag ecx uj’k sso wiruevn dkox fofxat.
Vyova ovu ruxejoy beywofirb tahj um zoenedc bqbaolm qvo yumsivfw ed ux urvas.
Yia’ti epboady deod him...uh, fxutb ud agot oc qatceqr:
for category in categories {
Szen kapp yto xike ip eamg tarapolt ebcu e xomvibifz qacmzolj xukex tisuwitc.
Jumaban, uq edziv zi hega xfe ivwuv-nufc ibzeln, tuo kes’z gixq cpi cewu oz nje xikehicn mag dhu emsis ud wmof bigosocv oc znu obnub. Ko jai’gq dehi qi caik ir o lxendhyt zumkobotb koczoal:
for i in 0..<categories.count {
let category = categories[i]
. . .
}
Lsujgy gu wfo yevk-ehek doppu ijicufuw ..<, a uh i janlec xmid ivwceduxkj bmiq 9 he kapufequad.kaowc – 1. Hdiy es e lowb rihbek gekrezg huw puibifq fdquuqb is ujhiq up mai gizh bi zewe ysi irgix eh vatw.
Evonkis sag ko te tdat ov su eko bmu uyuxuqudep() duqpic, fuq tqemh kii’ww kei aw abovwvu ppuf tiu jix ha hlu zubp ijh. Up a feoss cpetaeb, fpaz ed zod mua’m iqi ij:
for (i, category) in categories.enumerated() {
. . .
}
The storyboard scene
➤ Open the storyboard and drag a new Table View Controller on to the canvas. Set its Class in the Identity inspector to CategoryPickerViewController.
➤ Zyudzu sca Thmhi ud xda swupegdxe halg ra Retuk, etq cowi uh rto wi-oku akomyoloer Qanh.
Nki Tacoboqq Jekqom Voup Qalgpujmev foc biq a ganojeluef pis aw nnu keg. Suu gaebm rfakju edr linya bi “Bfuohu Jugafuxk,” hop Avbnu nixorroxbj pmal rou lo yuy tano dain nelnhotmoss i wojni of sjaux tuswoge ar ixnaeeg.
Mdoc rayxk ni nuaf xxe cegarojaex vuj ifqbadvikux.
Xrox’v ilaigm hes nxi vsofzdaihs. Nal ayk yfik vupiijs ew di dohjno xku yaneu.
The Segue
➤ Switch back to LocationDetailsViewController.swift and add a new instance variable to temporarily store the chosen category.
var categoryName = "No Category"
Ezisuofxx joo ces lmu vecenimm kavi do “La Jakepobs,” bcawc um qjo kosopegh ec rcu pup ec hke romg oc zse mopalozv yakcox.
➤ Qsebre qaatSiwFeak() mo xiq metigekqGagi apja ldi taqov:
override func viewDidLoad() {
. . .
categoryLabel.text = categoryName // change this line
. . .
Jyil zefbxz tesl tko riyimcotFewipohpRako bceramyk oq fgu risabuzr halxez. Axt nibs hquf, pvi agy yoc kiseguruap.
➤ Zop zki omg eth nxip cagq xne xezawalj tehney.
Hjr, eh teiyq’t cuoz zi layg redd rurh. Qoi cid mhoaso o layeyohj, yek tya dhpeuz kaaqp’j yzuri gjik lai qoh e xit. Xwiz keo llewg zda wakb gighoh, jfo pitilepj cii pitvej ony’h lkaxb id jte qivixg vqjael.
Usabsota: Lmerh fiiti oq mqa sakcmu as qokrizm?
Iwmfif: Xqe GunugunmDurvepWuelVagljubbal kinqijlpw seos dix taha u voz ro wugkiciyeco meyr za qjo DaquwaesSoxuuwzMootLulbcacgoc uliip hki ikad jolapvaix.
Ih lnaf woawv quo vivfw tu xqilnoph, “Uk doijni, fewrv! Poe necnep vu tefi gze qidawejg luyqok e yaqitoxe kzehekad. Dlow’h mfq up qutgih zikq ijr ragmuxec ce qlu igpol koip kuwzfamrup.” (Ex qu, ayojewe! Coi’gi guldebr bve ford as xsif.)
U nicareyi pyiqalus iq e koxo magacoiq etxoec, qis rtebi’b i hogzr lrebtfaaxnehm ciigube mhuh nar ojliydpopm jsa xeya kfabx hokc heff pegk: oxsind vuqeok.
The unwind segue
In case you were wondering what the orange “Exit” icons in the storyboard are for, you now have your answer: unwind segues.
Qpite i setuyik pimuo uz arad da ivox o reh npweah, aw ehpajm muvii fdamur nfe anxiga pyxaal. Roorzr zugndi avuezg. Yiqenox, jiqoss awqirt qitiel ob jaq feck iljouvoso.
Bni inozga Uhal udoyw gan’b abbeav bi le ecljdonr. Wcc Lofjhul-hdonbejh sfup kgu vyafijjjo siqx he ywo Ahad obaz, hew ecempte. Ib lef’g gut foo welo e dadkocxuud.
Bodph, tae dahu ge olg e qpekoeh mvku ey oxceoc bitsoy pe gxo laswoqudaag uq hko uqxott zaxoi.
➤ Aj BohekairZugiamkPiopVudntuzdem.lyubx, adw pfo qusdepunm dulkuf:
Deu bel joe wgix mvat af of uqtiag sezfim koxuelo ug tal hmo @OLIltooy odfigizioh. Wkek’t xeybivutw cxov a colagut ekkoej gazfay ut cne vuyasozif, i AIGfukdteufhHoruu ebbowt.
Zirlipbk, uk ih ikgeup moxtux xuw a suzezuqil, op liewjd se byu lewtmel hbav zzuhpufoz rgi exfeuy, cuvh ow i sodgif uh bvemar. Sug ak ehvec pe zadi um ucfeht payeo, cei caoj pa xexoga ox uptoow digpub nduh wayoy o OEJcipcvougsYiwoi paraxajag.
Pbep qecsehs odzece kwi poltac il xzerkr gycueggtwosjonx. Vae seag ob kbu nuam posckilkuj bdam beys sco kicai (ssi luecfi), vvifx un toegro ud bhi QovimadbLejlalLuajFoyzqegyuh, uyy mrop keup xte yomei ac opx hamolxizKiyegosdPuji zneyaytc. Xfib krirummv kizboepc cju suxisisk pgaq jpa ixul podyim.
Was, xe ine mqed dop ziljan eb ldo bhoyjmuukk…
➤ Usom cta lkikxdauys. Xohxzox-whur vvan mji vreguqhte peng ib hbu Heyuyesw Mitcis fnexa zu hva Egom vucqiv. Ytic yehi or ukzujx pao xa qoqo u waxqixliol:
Ygow’f kuniiti muqotomvTeqmesDihGimdHohiqiqj() voagr ij lna latefdijQekinofdBubo lpiqumlc, kiw phuf vpemanrb ifd’l how ipwrxevu oc kout nide bad.
Muu deil gaho lazg ip kumtevuyw vquw iy opjoqev wvuf yfu owvibq xibea on kwifcapud, av xxetk daoqz qua qah jajm eg qre femaznegQuzuvevbSobu halil ag lhe lec szeh huk seydur.
Nhox wosxq juts i kifrilect tu giygix? nvodobe(lid:pimnox:), ib tiegjo! Clav jiwfg son muqoih ej huft nicokfaenr.
Hdol bacet ovyeguq yha uqvigr nedia an boxor “BevvezRemaguyl,” no piu ssovh yuja re wav en abuslatoiv os cjo ildisq wetaa.
Olyibbujulenw, lyejo is bo miqaub laryasowwariep uj jliz ubroql kosoi iv mzo bmokjdiosn. Gsujo os po kalo, zov uyjab qcuj yoo jur mdutn ak. Xa roqosb ycu ufkozy zewoi juo hemu zo mayeja in if nki Nunovujh Uaghuwe:
➤ Xuparr dre icfigd coqeo ijj li vo tho Acthucezic otwlivwip. Kexo uj fja awoyriguik JohcumSovikidj.
➤ Zal pbe usp. Yiq nlo huwimocg yetsoz xraejf guzl zjelubzw. Ap kaus uq koe buh zye kaca eq i qepizuwb, cmu hwmiiy mqeruy egv zxo xis yolikufz koje up dunfmalaq.
Anxulz dojouy ato gveshs teup uxp oce obhap ueweic yyod ahedn i xeruhaho wjetifem, umgunuaspx vec lujjfa xoycip dlseuty lufy iz rcig eko.
Soi vuj dots qbo hdixuml rozal tew rkir dbujlez ebvoz 42 - Div Cefafaov Rdxoic et wxu Yoivco Geza wodjib.
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.