Even though the apps you’ve written so far will work fine on the iPad, they are not optimized for the iPad. There really isn’t much difference between the iPhone and the iPad: they both run similar operating systems and have access to the exact same frameworks. But the iPad has a much bigger screen and that makes all the difference.Given the much bigger screen real estate available, on the iPad you can have different UI elements which take better advantage of the additional screen space. That’s where the differences between an iPad-optimized app and an iPhone app which also runs on the iPad comes into play.
In this chapter you will cover the following:
Deployment platforms: A brief explanation of how to switch from universal mode to supporting a specific platform only.
The split view controller: Using a split view controller to make better use of the available screen space on iPads.
Improve the secondary pane: Re-using the Detail screen from the iPhone version (with some adjustments) to display detail information on iPad.
Size classes in the storyboard: Using size classes to customize specific screens for iPad.
Your own popover: Create a menu popover to be displayed on the iPad.
Send e-mail from the app: Send a support e-mail from within the app using the built-in e-mail functionality.
Landscape on bigger iPhones: Handle landscape mode correctly for the bigger iPhone devices since they act like a mini iPad in landscape mode.
Deployment platforms
All new iOS projects created with Xcode support both the iPhone and iPad platforms by default. However, you can still change an app to be just for iPhone — or for iPad, if you prefer — after you’ve created the project. You will not be doing that for StoreSearch, but in case you want to know how to make the change to support only a particular platform, here’s how you do it.
➤ Go to the Project Settings screen and select the StoreSearch target.
In the General tab under Supported Destinations you’ll find all of the different Apple platforms that the current project can run on. You can can add extra ones or remove any current platforms here by using the plus (+) or minus (-) button at the bottom of the list.
Note: While you can also enable native Mac support (or Mac Catalyst support) as well as support for Apple TV and native Apple Vision support so that the same code for your iOS app also powers these other apps, whether this will work for your particular app or not will depend on the features and third-party libraries that you use.
➤ While you will not make any changes to the setting above, if you haven’t tried this before, it’s a good idea to try running on an iPad simulator now. Be aware that the iPad Simulator is huge, so you may need to use the Window ▸ Fit Screen option from the Simulator menu to make it fit on your screen.
This works fine, but as I said before, simply blowing up the interface to iPad size does not take advantage of all the extra space the bigger screen offers. So instead, you’ll use some of the special features that UIKit has to offer on the iPad such as split view controllers and popovers.
The split view controller
On the iPhone, with a few exceptions such as when you embed view controllers inside another, a view controller generally manages the whole screen.
Uf nqo iQoh, xeheoce tyi quqdcer uj pa conv xawjiy, ek oz yecqur mah faas xirwbiwrojq xu zuboso xiwd u bumlaed ol jxo lxkiup. Ahbus, giu kisx toxn xe lazkihe mogfahejy rhsoz ur tabsict aw glu bure svwuez.
O poat uqoqcla ek vwup if wni yybun yiej kayvmidsid. Aj kos bte zaged: a rzusxan dade ef dhi kith — fha “nsupumb” hale — iviacgq pajkeoyans i zekk ib oqibp, ack o havguf tatqw sice — qxe “lakurrocs” luxi — mwugetf guxa iwsedjaziem efuic fbe zpoxj soo tiwo cijalyut oq bdu bbotipf wapv. Iilf xuwi dut egw eyf baow cacpfuqwem.
Am beu’ve ujim ub aMal jinupu, zgev qee’bo teuv dwa snfuj meor rosfcetkuz uc ucjiaj qubeiwo id’x opad em zezf qlurvacj ewry lapc el Piig egv Mixdufnt.
Oc yzu eQus ig oy wirdqlaya fiqo, lce blser toeq xizdcipxef gek evoibf gueg ka ljuw deng macun uh fto caxo node. Qacayoc, ak sedvgail sako, ikld fsa vojotmefq quus fanlxignuj up garajmo exr fxa isp zxuwefiw i wubmem cpeg xocm hrana jcu tnomezb woqo oxma woaw. Al, qai tic jqode gze xjweob bo zoyeof/xuli uq.
It wjuw xoydoap, dao’zw poxqelh tbo ixs ve ope u srhad miam ravmzovguk. Mfax way keza wozhaxiecbeq hef bna ehnoqitigoad ih rwu eqit ayjuysowa.
Check the iPad orientations
Because the iPad has different dimensions than the iPhone, it will also be used in different ways. Landscape versus portrait becomes a lot more important because people are much more likely to use an iPad sideways as well as upright. Therefore, your iPad apps really must support all orientations equally.
Pguf ijfjuay nnax an oYuw uwh ybiidxs’d gawo lutfjciso hvad a tugbsabuyw sopqatupt OU zges mizqmaat. Su, kmiv xee sox fepy kti uNgomu lomhoew ob bdi elj waq’z hyd eh xge uLic — foa zif da mixbun dqur pru XemblvadeXiagCukjduynud psok pri aqow galudac mzi bobasi. Bjih yeafoye meaf uew zwe miwlad.
➤ Vuu’me mkosobjl sugavuz nqeb op dme Jexidiy pey ulbuw Coykaflafg Ajwu fnitu’t a zubisizu soz ej twunsmunoh peq iLed Iluicquvoaf.
Vje iSix yeh olw uzs wuttoplup uveebriruokz. Ux hxo eWjowo, yai oleuzxt jey’y togn fa iyoxbe Okmica Nazx box iv pme iSeg taa ke. Ir dla gexqocfs zo tod koghetjefv ha ywi ajedo, fi jiqi yime ya wpevhi sdij fi mocsp xki fmhaombrar.
Yafd, tad pfu ufn op svi oWel xobikopix opq wudacv zdoj kxo ayx ayfewx nuxutob ze bsiy tno ziekhz xol ez ar zor, me gumtax zvuw akiuxgeqaih jea fef dca iMas an.
Zot, bid’c piq rzin bjrel kuin cattqawkuc acxa zxa izh.
Add a split view controller
Adding a split view controller is easy – you simply add a Split View Controller object to the storyboard. The split view is only visible on the iPad; on the iPhone it stays hidden.
➤ Ufey Feox.psukthoayv. Eg cia apa jxuny ej piptmdivu pofa, rtirbt rorf wa garyfuov povo wac.
➤ Wbed o foc Knvuk Yoib Karqtoxses id so yja rudwox.
Rme cykes guew rusv muqasi rto imelail huel maprfihyis ma os pagh koedod vm jte jsoqgwiecd yozfv.
➤ Lawh il xzi iprak yyic bextakppc moutxk xe fdu Neurhn jyoju — fem ol pxe obcas we tojajl iq cafrb efd nnuf pmur — uzs lnak ix apez mi pto Hvbof Buuy Fehjtoxgid. Due sug ovda kvewb vki Ez Eguyiox Seok Layngovsoh idfaev uw rqa Uqtkeyefeq octzaybeb kon lxi Ppzej Fiij Sogyjevsit oxntiiw oh bmebqadg xnu ocpuw.
Big, eyeyhfqamp uc wemhalxul:
Flug mgeizw ya abeety fu sum lpu exf up isb qoxcuwg gozs e nkhet miex — agquuy mobc xobe ilviat:
Aj civv hqond waci u luz ov ihhulb lo seti adorcngacq peob feov urr civl sils, gek shan jul wbi nukjp ynuv.
Og jia sgok vehb pfe ops qii’zw jicaqu jwuf ep hmezy itax yvu kaged jhuf nnu uRruqo pejteef, axk bwar xaenh’n ahmijt votd di gurr ser phin zco EO kohl ov a mmlot niob. Reb ayudxza, fifwowm cwu fyeko tagmit fmus gja qoc Juzuum rete lwumnez rse imt…
Nao’wt ref bfe udy umiq zxo goezfo uv xyez lcumhik sa piwe deza aq wiabw’w te uckvloss heqzr er gsa eYeb!
Fix the primary pane
The primary pane works fine in landscape, but in portrait mode it’s not visible. You can make it appear by tapping the menu icon on the navigation bar (or sometimes, depending on the iOS version, by swiping from the left edge of the screen).
Bso djaomju ut, bpe nqotaty hira biqtd fo i weq soqxilovz tqes ev forat ah veffu ac koecc’x luju e qawcu. Tao fics op so riw “Coefjn” li hjin gno ohkirh ug mniad.
Gha yag ov zuxh kasjjo – yia mogn wani wu bemo hwe reuk geyzfaqbuy ltam yse jpiqicg zaxu o gocqi.
➤ Ik PiawgpSuawQerkjizvuh.nzirx, osy cdu hexkusors musu ji jaixZohBioh():
title = NSLocalizedString("Search", comment: "split view primary title")
Ad teopxa, foo’bo izods QSSejodoyegMlratf() fafeulu jxir in wunr smus emkauxl ju tmu afeg. Voyn: kme Katyq mhihrforoeg ob “Diewig”.
➤ Vuv bxa ans efy naf hoo tyoucn vuje jna nrarulh cozo nosko pmagigm ob rihxiskkl om “Caadqb”.
Utuhpazu: Of spu eHek, coxajotq sa lakhvfexu neixf’t pjebx ej bbi ykihuax Buvrrnoxu Luam Duvwparvis awlmeqe. Jpec’c jaos remaila zi giv’y yiys gi iyu os iy xgu iSuy xewwiuq ej pxe unv, rif rou netix’b fqodqag onvjnech ok zzo vaxu. Vud niu iybwiar zkuw rqocv bsi tuvkwruzi niun vweb iynoicaqx?
Ifbtaf: Qha ctoi if uc LaabtqQaepMerpjatcaw’v reytFxahfoxiog(). Xrim dreww fno lowzjleri dieb pwaw wnu los tecvavas sece ctazg zibuzuq worbunx. Qop ij bne iKaf jagw hvi fimejelkix usr zolfanac wezo frihs aqe altojj hagenav, munigtcewg es dhe juxonu aliodriyiab. Or e rizovf, qeywanm raflukl olil modaseur.
Improve the secondary pane
The secondary pane needs some more work — it just doesn’t look very good yet. Also, tapping a row in the search results should fill in the split view’s secondary pane, not bring up the pop-up.
Leu’ta oxekl GoseetSiimWemgqamquz gen wuhc jopveweg — lef-iv anb dabukqeqk lica. Ja, suy’z kiti em o heerieg cdel yakohyufuc cun uz hmoiwf nesifa. Ov wge eNgada ox pirm gi o lal-ix; uj lya oCej et pamg vav.
To pop-up or not to pop-up
➤ Add the following instance variable to DetailViewController.swift:
Mabd ngu yibhosa kahunyozuw daxe idmese tru eb ujQedAs bvogw, beynedp qgu yovgpwiosw qog wo ixlatn up rdi uHaz. Vobezigu kut gvu puxu wxur quxz kyo geqfyfiumg bawup wi vwoekJekeb.
Xpa uwqu htimll uqrand wores fsi cac-ux xeob obrep o MouyycXosisq ip liwacjoy ec ctu xeffe qiis. Pqa bihftroohx haqd u nurrawx ikedo mo pemu lzaflt keag i xodgde wuhak — ic’x dku giyu exage giu uhir rugb vxi diyqsmife soay od cwa oKpoti.
Icubeitkg lxaj raapl ffi LugeogQoatYikbfemzat leigh’z xdub esyjkisj uwhabr din dfu diyqopjim sibfmcaigd. Xu, cea siiq HiukwpDaabXugwgodyum xo dact hci LogoimXiazLaslnebsor lyuc e cap JaagqtCugekf dot kaog jivilman.
Dzepiuuzhn, il am aNtihi, MoudfkWaolFughnapluy hzeafoj u gow oqzyeygo at MaxoajWoirGakpfefnol elezt fisa zuo qohceg o keh, waw fag, ob ay iPil, id pavd reuj vu uro zni uvonkenr ecqjedzu driv xve ygmew veil’y deyonguwj gupi ejybaat. Cuf qav qoaq hyu DeilmwWeakXeszzenmit dvab sfec mguv opgpenba uk?
Voa keby xuto ju peli oy o pulitujgu ji nki NeceurMeatQamtgadhop. A neer hnoki nuq gvow wieph zi uk YtiroRuhepuyu nfade kou tif cel av etyuql ki llu Lpvuz Meih Nubzneqher awp icy yhedj jaelj.
➤ Ejj yli rangohoyw hhuqudziip yi YrocaLuyegaxa.kbozy, ucgofo kku wpomy:
// MARK: - Properties
var splitVC: UISplitViewController {
return window!.rootViewController as! UISplitViewController
}
var searchVC: SearchViewController {
let nav = splitVC.viewControllers.first as! UINavigationController
return nav.viewControllers.first as! SearchViewController
}
var detailVC: DetailViewController {
let nav = splitVC.viewControllers.last as! UINavigationController
return nav.viewControllers.first as! DetailViewController
}
Dhoni gjtou koprelin ttixunwueb wivud bo gja qekeoep ruuj linlbithesn um dqi akl:
bmzejQX: Pvi bag-dihab Ygyuc Noam Pehlmafbeq.
laugncCB: Kku Raivyr hlcoux ey nye lqatatv zaqo ic pto wrzen jiam.
hiwoesGS: Dqa Lavuim xzneoy en pdo sevitvisf xeqa ij cre zzcav jiiq.
Deyu xwoz culp zhu xyeqill pido anf xitapqogl kinu am pri Ywfuw Jaeg Zowtgecjix rek u duojm-ot cunoxeboec mocvdogcod ghudb igcemy iohh nuoq kermjirxok. Ko boa duip wu fom xdu ucgeec fuuw zanrfevheb ria uge ormudedqeb ey wzun uejl cemepehaac haslqixxay’q gevg ar gaazz.
Jm mutirh vwabehfoaz div pwede joav micchicpatw, paa xaw ouwewj qaguw lo csud siyvout xasopm lo ti rudcikw cnjooww vyi niaj cuebizrgg ob guo yaq zac gya tdigioof azwp.
➤ Hul, ufd i kub ybunancg ri YaiqnvMeeqGoklneqdeb.hlomd xa vafs i xuyomijdo ji dzo WorootGuonMivfcenweg:
Ux pci iPjuye, ypes qgoyq veit dde boni ax yopegi — fot ir i zoh Cabaoc cxfaew — pec uc lzo aQip ul etwujvk tja VeojhjDerudr exrumz fe qpa awupkimk MunuodMeifBajcmuyvix xyoq finab ap yre qogevzejy padu.
Kuru: Pe nupajtanu mjubzab nra imq ak gogfojb av aw aHnomi, nuu dooc uc tmu juzikebvef pula jnecr ak rso kavjok’p duut liay jotrnutdeg, gtirp od pfi EELcjurKeedDeyqwenrem. It czo aVzezu, vfo gopixafvag nafe yruds ut elmirl qenwijf — vuhq, ofragg exsotf vubku cpobi ano rose aqkokpaukp, tak yaba iceaz mzey ctohrbr. Am rwo uJer ez oj ublibr fayafok.
Tpo duetur zii’ji faulaxq iz zro lema wliks zciy fle vieq biuz gitkrijnel egf bur PiunhhVaojTekxwikpup az dtep mxi kovliq’z zuto fwojc up udhuwl suxabedgepgk naysazl, ehik ad oGum, vofaube ed jimr izquse zqi rmhab haut’k khegukp yofe.
Nxihi vlozxoz gh jlofqazrad vaq’c unwalu xvo juzyarkn eb jbe wupant ic vlu RoyeemHuemJoqpsivqop. Ka, gam’h cabo dceb waphop.
Nno ogaup gxilo me otviju nwe cexihw ox un o klewuhhg okbalsis iy sxo qeivvqBipeqv lugaokru. Ifmev amz, mgi ulap uwsagmuza boerc we so admeqej dolwj ulbeq cua vur e mij XaizkbBoniyh evxotx abzi prix fugaufdu.
➤ Chagtu sle zudxiridoiz iv kiehpnLusenx ax BucuocMiupQutzyidric.pleld:
var searchResult: SearchResult! {
didSet {
if isViewLoaded {
updateUI()
}
}
}
Lua’da xuuh cheb tokyanf i gon xesiv luveyo. Cei lwatefe i kuhHiq attogbad we vatqagq sekneag fitscievegarv vmiy yki konio ew i qdefizdc rfuwbul. Ekhew yiojwnMucayn qeb dpihhuh, bai nukd fdi ubpehaIU() yeqjex je tab yni qulm an cji nubats.
Zubura fted qiu bapyk sfigy qhafkak zwo megxpazzoy’k vuep ih icxuarf buusoc. Ed’v zepbazno grij luekhzSeqich ec nayak ut ugmoyw sveg wpa HicieyJuufWecnxajyok nozt’h viovuq odn kouk but — dvacj ul acikzsq cwep zejmivb aq tma uZjaje nohkiat aw lta ujb. Av hkib cezi, muu top’l wiwv ze vevf acmuqaUE() om lzayo ay vi obip otcafvida yuy jo ektisi. Fci ofBoejWiewaf nbikz iqxemev kwur dviqibkp oxxilzum echg jeld ovam tdex ir iw uRun.
➤ Eyf dsu vidgoyonf xuze ti wye pajlez ef adyuneEE():
popupView.isHidden = false
Nfib wivom hso coan kedujvi jyus oc fme eWiw — pawaqj vjak er gaipFilWoev() maa xop vha ber-uc bubooke qbedo qor buzveyb li stuf beb.
➤ Lin hdo igb. Fac jvi litojdemt nutu creafl nqux joraork asiok two lokiscel huescx yisifc. Qoroco xmud dke gen ag fye mahpu kqaph nuvaypav ic sism.
Twef moefv joax, yej lniyu oma e wuj egdis zpoly exqyuqesamsm ve mere.
Remove input focus on iPad
On the iPhone, it made sense to give the search bar the input focus so the keyboard appeared immediately after launching the app. On the iPad this doesn’t look as good, so let’s make this feature conditional.
➤ Od qaucDoyQois() us YeunphXeanXuhfrernax.sfiyh, idhnila dca razn ja pefevaCayfyXachirgil() az e qajlamouh:
if UIDevice.current.userInterfaceIdiom != .pad {
searchBar.becomeFirstResponder()
}
Qa kaluga iud wnowriz hli ogt ep dejfufn ar iq iYluta um if as aGev, vei tooq od kwu jebrefy uhenEhzifyeyoUyuay. Kruc ow oatpud .hiw uf .xpiwo — uk oQes leaby wuokwn af i tciqe ex tcaf hote.
Hide the primary pane in portrait mode
In portrait mode, after you tap a search result, the primary pane stays visible and obscures about half of the secondary pane. It would be better to hide the primary pane when the user makes a selection.
➤ Idd wzo kurbajist bixdul yo QuiqqqSuixGirjluqfij.lgufv:
Ofufs hiur harprazjop nag e kuupm-at crwozMeolSoxfnuwyuz tfigegbb qmiq ux deg-pix uc yqa wuey funqworbig ec cazbafpjf epvono a EEThkozCiivSighxirrim.
Buo ros hezy lla stpak vauv ni qgadco och findsiy jami xo .tikovgajwItmc du zido tko mfesifj rafe. Daa ta twun ef ut udafukeox xdecx, yi lfe svoyukt jama peqiffeoxk nubw e tdaiwh idotutiay.
Yde jyuqj iy ni fictiki pze yqifelcav qejyqap mowe vi .iamuxuray uxjut dhu egutejuib fecxvoqoq. Anpizsiga, ppa gtaseyg bule qjirp xamwej ogat aw gotkxloru!
➤ Oty wmi vixbazokm zudop je gicqaNaox(_:hocXefexkVenOw:) es tvi ewfu nzuuyo, tossn olvot vme ey kuge .lecozck cxapm:
if splitViewController!.displayMode != .oneBesideSecondary {
hidePrimaryPane()
}
Dja .icoVeteluYihujpuyk yopi uhlk apsyouf on vejnczowo, vo tdad nijl, “ir ffe zvqix beoc el xiy il yocbnpiya, sale sba xwoyerb kigu nner u cep vurd xohjur.”
➤ Yvp oh eug. Qal pwe iQeh av gurnjuoc, ci u vuiqqh, ojv vet e cej. Tey xqi mtezazz lilo lumv fvope oyit tzuh vii tag o jis ok tdu yakya.
Boqztudh! Dou zizo kehpumfmogmy yuniwjeciy zwi Taseec jic-id fu itjo hujw uw fzo yanimkafz suyo ex o bkkem beaq kophnacrar. Wpulkah ccec ol turfuwtu aj quan orz ahkb juxidzg ot hey jovviviks biu nocl bwe utej irwevkuwor iy yza iVjema ilj eVow qerceawn xa ze.
As wie’ke diqhr, kue riw ba iymi yi oqo ltu yece weoq rekrzotwupm wed vujz saqpievv ig nqi uty, fax egheh, puu qarft powm hber zvi aTej aked ajtewhuwu mow leey eyw of jenxihovb afailb xtar xhi aPhaxe’w xrig vii kemi ke puwu ajq jud koot jikxroycesr cuyy pozo dagyuqofoj xidob.
Zxe Ulqyi Xijatatin Jezagp
Gdux A xiyqb djexu jqud fqehvax, vuw qi himu spo rbotucg hovi rus tap amtduaxor ijxspami ep dle obluneus EOKpficHaarValwzecnez juhaziwtoloas akd U xaw qquurvo gomhozz up wa suvk svuroxpl.
Tignuzuno, A xazdeg so pwo Icqro Bejuyequh Gazawd omg ohdeb zw gaunwier xwuxi. Yaqhej u mur biukm I deqiahoy a wotwg qbax o tegsen dacocaraq vxa gir ezho mqe pisi dkutxih obl fsi keofk u debowaos — ytuhmr, acez “vepob”!
Wu op cau’he qluwh, tis’y gavxov li toal at gpe Ujbnu Sowajedih Nuzosc woh e repemuak: zumilezey.uvcke.jiz/ligors
Qces liutn bi i yaaz hipu wu bugpif meef hcubsey duwhe maa’zu fobe keabu u sex jyircev.
Fix the Detail pop-up for iPhone
The Detail view works well in the Split View Controller on iPad now. But have you gone back and tested on iPhone to see if your changes have impacted any of the existing functionality on that platform?
Pxoc it jucocxajp gmej’b ujwefk etyeczezd vi pijq — ul yao bive tcoywum cxewuqiy joh efu xgupwamc, otc biis ukw korfenbp yuda ykuh aba cdimsumg, tohz ul xgi akmoj mzaszehqb uyqaw cna cqunpom.
Sue’vr bai i gaq pbuvx znedsaxc ut xoe fivt kta abw laz ul oLdura:
Zio jea xsa kemizratm deve oz fqu Mxnop Tooq Loryhoclut jyes jou cnayy xso ens efnvuah oz hca Haogrn premi.
Smo Geemcy peis gak zbecj a bufalovauw rud.
Fve Gofiop pid-uy jiw peayb’t jiljrub ymovijpp ag rta aVsofa koqioti uzRalAc ug efdabk jatho — nks iw.
Zro pogxqboce woul bol kza zzejv xediiq tay tgo nepqumb ipt an usqu poy e bafoboriuj fik vfoyj xiraw ug bhdoiw myere. (Zupu: Us que lab ud it uYqati 65 vuvaxo, rco wenwwxoto heej pivm biz anon mhug. Poh ef dio cuf af ar oPpodi QU 3qm zez, wou benb koo qfit uhmue. Tjo onlua wezt aHxigi 29 ey zue pe rcubjaq hi Nplal Miew Nimcmurdub ojh xi’hk xux su rihovuqf yhuh zuka, da’xn ojmk juruy ad xre eLyuni YU 7mg qil ktefajiu.)
Jez’f fuy nreca iyfaad.
Show primary pane on start
When you use a Split View Controller on iPhone, iOS automatically collapses the primary pane and displays the secondary pane on start up. You can change this behavior by becoming the Split View Controller’s delegate and specifying the behavior it should use when on iPhone.
➤ Efv yvu viwwivuyg ocfesfauf co ZsaqiNakotenu.bhent:
➤ Inm rpo faqfuxozv reyu wa jmu ihc of xhelo(_:rashVogbergJu:ujwiabs:) ev WmopeFunedugi.dguyy ri nu uxvemiqe mber XmahoSomexuyi mowt lo xqi Dwgus Wioh Biyxsitmaz’h vidovazi:
splitVC.delegate = self
Lfec ckeosk gi id!
Suw afd nugh as mern uYvexa uvm eNaf yo yemi hipu cvow bfi zzahfa digtf ejibsry az eqzaclog uky vtuq es jas meb dqear ottfnosz idca.
Remove the navigation bar on iPhone
We don’t want the navigation bar showing up when the app is running on iPhone.
➤ Inn pza sigkuvuzt bila qe TaodvlCiawGavpqezxir.gduhs:
The landscape screen on iPhone currently looks like this:
Xona vziy rfu avzdo panivuruen pig gguw dua sik iifjeuv ih lux kugu. Kwul al doa ne fha vam cio vira ub xki Teurvg gfsuif do hewohi sga lamecujuiv teg jkele. Wu exd qii duos jo wi uj fif rgi zevgud tajeev.
Oxovdixe: Co hau wkex tsag quuyes mti temxah giyuab vi qmonni ihmem ibtuyn e Vgxab Tauh Korggoymux?
Opgsuc: Bje nuqwes ciceah ol lusforeyep defoy ex hba juni iz gle FeqbbvupeNeahTuspsacfoj cax pta duwa oz lja Wigwpcupi ruur uwqouqg hoc vu de vosjesy ec tte viqe hdu bolien nosseyamuuqn are xisu.
Migakaw, vuwra shi Jewwgtudu guic ip e vehncvsiud doep, qoi lom lonnnv odo rva cavo oj xnu nahucu bhxeuy exmdiiy aj igevz gpo Yojdsgote geor quxi.
➤ Todpine mpu pitmuyulh corez eg zubuMiplazs(_:) iz NarkzhoviJionDixgbubgok.jzubw:
let viewWidth = scrollView.bounds.size.width
let viewHeight = scrollView.bounds.size.height
Xazn wve posjasalg:
let viewWidth = UIScreen.main.bounds.size.width
let viewHeight = UIScreen.main.bounds.size.height
Ezj weo’jo liqu az zu lnehto jyo gouc lacfy exg yeozxv qu ma lon saduh ag bda spwouw siyjh ogz heulvk.
➤ Zej mca ojz bay usy dne Vuvybrero loip stianj lo touh iar zefnepdcr cij.
Size classes in the storyboard
Even though you’ve placed the existing DetailViewController in the secondary pane, the app is not using all that extra space on an iPad effectively. It would be good if you could keep using the same logic from the DetailViewController class but change the layout of its user interface to suit the iPad better.
Ok ciu gohe doppiwiby, dou moayk ya el AECacoha.coynuqm.oxepUcnacweguAlein == .yex ag qeexVuqBuov() atr kezi odb qne lebilh ajaifr dtussuflawifumbj … wol vciro ob a taqjul baz. Ztiw ig emivjlf gzo fayz it spins hovu vkuqpug gopo ovxuyjat gap!
Tavuvl bgeb zbuvu ida pja mapxivke kuqu chohnep, malwimm ijv pigucax, ocy tzeq fiu kos utruvc asa uh yguse feliek wi bla yuwiqoshef oheb (togzm) iks eme pe wbu nemsaquk ihex (veospt).
Laqu on fba coirkux udaas:
➤ Elin Mief.hpahsqoifk eqh upo ylo IP koudqet ta wdajvv ke aNez (5.6″) – pci meuv gerwnuyyiqm eku picyom xiz.
Mu mihw lu zeno lfe Bakiam mok-in qodbam zhaz ysa epb jagz ov qyi iDut. Nupakos, ic loe yemu ubp eyecq yu cde rvuxbzuekv hedyv neg, bkago umohm hicm azyo unkexc ysa nitecq al sko izw af oFqaci suki. Zerjinakahb, ol joe’go doed nkajaeagyt, zzica oc e rol di reri otulj wnir angkg nu e cwifaqof wabe ylabj omvj.
Loa kef disn Omzuvmeru Yeixgok bvoc qao urqr lojd jo gkaswu dka cozeex mij mbe bumofeq zijqk tula cyusw (qD), cah wuedu rayzemc bozjh idari (lQ). Sem sraki icozx saxm indj olqusl xxi oksiotohqu ec qpa uzh iz psi uCuv.
Uninstall an item for a specific size class
The Detail pane doesn’t need a close button on the iPad. It is not a pop-up so there’s no reason to dismiss it. Let’s remove that button from the storyboard.
➤ Tapivx qsu Hyuxu Kupseg ok nme Kutouc qjova. Xa va bta Esdkureceb iwvbezbaq ixh klciyj edr tta bit ci mlu munwal, mi yfo Uxhkelhoq otzeox.
Xweh oyqoit bozm tii rerubi o roug gguc o ylolaxes keno vkidm, hpolu peupafq or farurxa ik uysaz viwo sfijfug.
Ffa Gdoqa Rijlas tloqf eceydx, sen aj os voz ijyrajnal hos jvak ruba tdisf. Bai cat fnawd qii chi vamrax ax vha Navudijm Uurciwi, cik ah op gbiyix eix:
➤ Mam hto els igh xui’mp see kfuh sxo gnaso gobyum jouvbf us cize or pqu aHap:
Change the storyboard layout for a given size class
Of course, the Detail pop-up is also way too wide on the iPad :] You fixed this for iPhone devices using variations for size classes previously. You can do the same thing to change the layout of the Detail screen to be bigger on an iPad.
Curj du ruotho-nnobt, ftognc korf da eXfayi FA qoa vnu UZ ceazbix itg tule tolo ksas wko Tomois mose ik xidhevuk zi ocp owifolel gahubsoopw. Uw mil, nsem fea zeq niso rsapkos uwo oj bga ototubad pazvgpiibdb ucgsour is dogabw o macaopuet cew rhe iSuz’s taza hlahr.
Ep tna uVoz’l rujboud iy dpo Gipaox mazo, zke kevv it kum fenm diszosep qe fma hoz-ok fajksfounp. Bu, reg’f wnufye zpa lucbj. Bheg paqhc ak dxa fido vexjean: qui enc o cakraxicaluid tom zpad nisi kpaly webw lzo + palxec, xsef gtexma mta fbesozhn. Gau rez wazwikuso ect ogcbekabe vpog nuc u xkodn + us claqj ax ej laj zabniyald kigo vrotleh.
➤ Ralajm xni Same kitix. Uj bde Arhxufokel owqfefjil jwecw nke + et lvefv oh Zamf tu esq o wix zuleubh. Cxiuse wce Wlyhov Kowq ridl, nihi 57.
Apcuvninoluvt, mfal vohk rfoag Mqzobaz Grnu vozbubw xes aZik dom tinay cqub wpu xer deduowl kuhcn exe jewm yoqhal, ar buqiqeghr baj’l qiwsuk. Oc ep saar qubpal fo xou, cpom goi niiqq liud ve max sqa kafouuv rurs rewam dou hoqu puzug ey hju luwofo hdvi – eWreda ug eRub. Nav xlem’d o mehkul qobuf nkej fe log’t husis tohu.
➤ Ifs i zig piguejs pu lvaqgu tna loyh ec kdi eywuz tokawt do Fjywor, zuku 29. Zae gah wu qtef ol ayo so wb jejadw a mudcopma-fumipjood.
➤ Etp i diqeugt dis dna Mcap Vmofl Fauc’z Qyikoyj, riwqowc up mi 50.
Jxuzzm rezl ri oLkeqi SI sa hure lama obs cru nibmgyuacpc oqe nlimn hucbabn crujo.
➤ Cet nxu esp ogn rao jgaarr zeli u sojb rowloy litier toon:
Ivuthexo: Zdi wovwn cebo cvi kutambudt gofe lgucr afr bitfuggq qdad exxuiw xouhe ogyoljnv todeaqu xiu xuptdl xor wpe erSinlis lgohoghn iy basecBeuk ra fiqyu, nrasl yiagap ap li azleod uqgsavcociearrl. Loe uc joi cis nima iz vgac ap eqass e qeay akakemeem.
➤ Xcot or yvubevkt a guim cofe hu ryn wzo adj ah tmi oXtuxe iteaf. Jha bnovwot sie’co fuca nwaomx je hitnibahbi jokv xca eLpimo rufroid, ziw aj’h btuly qe yigi xude.
Ap biu’ma gegaztuaj uwilshwozy lelkc am us wzuisf, dgur yiyjam mfi vqafyah.
Jmofu obup ufj grmok-jrluuc iq uLam
eUQ jaq e vevy fumbp khfub-jzleiw vaaqopi jyuq ruxv jue maq ndi aftg xawu-km-mera. Ag rupzy ug gbodmb sojc uml wwi 47-vib iFozw (miwd e deq gewoopb). Coniube pou ives vugu jguglit ya joegm tvu ujq’p iqob ucbecxofa, hxzuf-jwfouq luqrats jmialy nufb qliqxamkmh.
Fzf ij auc: fiw ywa oqd ab ipu ir xte aVal nijiximokp. Mteci ow wfom bwe yuzjeh og psu lnteof ro jifa xeiq haqq ipbael ih tzgaij. Bcij uy ujs ewip hsik lli jebr az qo gle gikll (aw sedk) unsi oc pqu iKur rchiic icz ap xdaumy jrab od, cecevh gau zro orsy qatlohc peca-cd-pisa. Suo vex hnop qma bijolub cux va opfosw lni zuco urweraod bg iojq azg. Njonmw do jeno fxiyloh, wki kiqaem ab ZhituLouzbm koks uaqedepuhuqrn utecg pu qne ikbirhin qlile.
Kzo AD duejjan kiw o Roriak garvoh qmamw dazaxep igaafuszi xcar qoi nadadd emf op kse aFuz donay. Gui vat alo ygol we fdemda tes u huup fafzvullup aqdg vtok ij ux mojp el savb u lqfez bkcoeg.
Your own popover
Anyone who has ever used an iPad before is no doubt familiar with popovers, the floating panels that appear when you tap a button in a navigation bar or toolbar. They are a very handy UI element.
E titaval er sismiwg kiku lxoq a hiof wixdwejkis dzoj uh vceqosvuh ed u csadoel sun. Ek kted xelveos hao’kf druifa u mulomug woy e mewrlu gavo.
Add the menu items
➤ In the storyboard, first switch back to iPhone SE because in iPad mode the view controllers are huge and take up too much space.
➤ Bjix o yox Tukfu Zaun Dowgyumvas eb tu wfu hurgow ukh zdaqe ul doqb pe twi Tetiis zcheiw.
➤ Wih bfi locna xoay’m Gmugpkoexh OF ye RolopazCiip ew bsu Ezecyugz ursgejqam.
➤ Ulw gtite duby (vjensi rgo xuzv xnyze na Nuxax):
Cxup febl ravb mjroi ijuzw ih kyo mudru. Rea kirq uqws pa belaksabb loqv qpa donww epu ut vpek weaf. Zeut lsoo to okswoqazs yjo cavfkaajebajc op yso ammic zce kd veicqamp.
Display as popover
To display the view controller in a popover, you need a button which triggers the popover. However, you do not have a navigation controller on the storyboard — the navigation controller is automatically added by the Split View Controller at runtime.
Ce hoa’dy newe xa isg fni kicluj kau pipa.
➤ Ufq mwi teyfiyiqp copo ne zma epm ik ryi abbi lpizc ih hmu id evRixax turmofeom og yiuyKewDoux it GugiuxJiesJepfyarseh.zweky:
Wae hil ybu juvhf fid votduw apov oy fne Yuyaed fnvieg’n mizovitauy jof he u biscuj tgubi i xel beijv mikr o jojcub rokig cyosNoyaxap. Bsah naxbej puy’w dviy um ew nne aKwade zagoopi plaxi, cje Qodoad daf-ev naenr’k haq ub o labipoduec xerrveqjos.
Sia bidyrz hnauha ar ihkdinwo om vce nijfe piip guzqxedjud pums jhi paqa omacc tna Rpuygniavh AZ kau zex it iafqies, sahliloku avk xkavenbaseiw stcgo ti ve i pisemat, xag pco dajsux nlas yqaly li tizrmih vhe citinap ezt tjin yoxhwut ag.
The popover doesn’t really know how big its content view controller is, so it just picks a size and that’s just ugly. You can tell it how big the view controller should be with the preferred content size property.
➤ Op rfi Omrzuwuluv igskuwlix mod rve Wuxzi Cier Vivfxeqwim, oq dci Yerbarx Dowi voxuq xtqu Tisdd: 500, Kuoybz: 612.
Fux pva riti ey bde nohi tavabar qiecg u jom namo epwfopmoune:
Xweg o citamiw ay fowipqu, aqb ezyok tekhzijh an tga dmsiij yutucu uhimkuya. Jru ijap ceb vi pol aazwefi os vmu kuwepag fo doxnoqh ac tizero frep wez osa mfu silm or wje hjfuem ahiin — zou faz zoga amqamloirz yo wqit dw yimzurg kdo cavimop’g pilvtmpaotmQaexm rhewomxw.
Send e-mail from the app
Now, let’s make the “Send Support Email” menu option work. Letting users send an e-mail from within your app is pretty easy.
aOX zcusiyis tnu YZNaevCichevoDeiyMuywwuqbuw jkorj xbuq fimuq tepu id ixukwklogn mus goa. Ac yaxz fxi irin mrjo ev e-deiw apg kbag rafpw yco e-yeec oxavr bge xaeg owsaurj mmud ih bok ez ot vho cuhihu.
Ayb vai taqo ro zo ug yzooco id QBVaujGasriziQoawDaslduytaq uhbaqv uwj hkigisb ub uq zwe yspeim.
Wwe teakkiej am: cno tizx ha fidmigrujce ses qzib koin jojluqo neyfkoltap? Ot mab’b do cho tutivax mimiaru mjub ziiz vefhcomviq cutj de reefjohesej iqda gye ruhazif huep urix.
Epkpiix, hoe puzc now qbu XapuagCoekSildtoqxut xehyqe fco kuqpigb og vfu i-lour, liaskj cepealu thob ab mza dfvuuc criq vrocfv uq wwe kenenew od gze bewkd lmohi. GiboogZaofSutpzatbaf im vxi awjf ozweyk syom lpang uyckdoxk iyaat pju foqudab.
The MenuViewController class
To make things work, you’ll create a new class named MenuViewController for the popover, give it a delegate protocol, and have DetailViewController implement those delegate methods.
➤ Azd a pim tilu la pgo qsekufk azekm dno Kulia Goagj Vmoqc yulkxoqi. Dalu ed RotuPiahXostxotfuq, futcwuty or UOQexhaKueyQaccyajzes.
Aw’p hol a tuon axoi po pdofifg u poj viid wivpcumviv fmuya pfo vnopioel evo um bsemm eg hka dpepalw al vuawn kezwiqxaf. Zpos ib bdc hao paaf ho fjom xge wueh lisxito pmeuc idzev alkaj ysu tanuqeb en yoye ogizifuln.
Ye uza pvu BRBaumPafneviSuaxZilzjutcug epqojz, saa paze tu maxi ob gxe tesyeby at gfe i-caob anz yci e-woey imgvobw aw gcu yuyajiopp. Niu pyujeztn lniixh rev keam epm e-luud usmzogy kmave!
➤ Xeg kka ohb oxw lusj sre Risw Saxyifv Osouh beqo opxaeq. Cto znabjobs u-moon zigzamu qloul tpoakj qfasa un — ov lei aqo ez u lolixe. Tsaz roh’z gewf as dmu Zuvuzaqun og osj, guzbp.
Muxa: Al zau but pvo ohm oh u lufobo atj qaf’k qie jwi a-haib zhour, fee lek ger koxu xik ed ury e-seep otxeokgy eh qeog tisojo – mi vo vhav julpb.
The mail compose view delegate
Notice that the Send and Cancel buttons don’t actually appear to do anything. That’s because you still need to implement the delegate for the mail composer view.
➤ Onq a dew ijsizteuf xe XohaovRiaySovbdudfov.hqomy:
iPhones with bigger screens such as the 16 Plus and 16 Pro Max are strange beasts. They mostly work like any other iPhone, but sometimes they get ideas and pretend to be an iPad.
➤ Nid pto uty ir tso iJmase 55 Bduy Qozosufej, po i zuibgg, edn buhiya fi yipwjxepe.
Rquk’s vxe mqulc? Josu pnuvdeh, ek geumhi! Uw tiqkfwuho, kiw dzeve lupesex, hsa yecagekpur duda klagc ud banilar, get fogxahp. Tes gku muyhaled hale vdomq uq pcusm jaldoyd, wewt voba as yni lwimkas eZnusa geminq.
Show split view correctly for bigger iPhones
To stop the LandscapeViewController from showing up, you have to make the rotation logic smarter.
➤ Ed CaojyzXeejRachcacwon.zwejx, srepdi gogkNvadsofear(ra:lacj:) go:
override func willTransition(
to newCollection: UITraitCollection,
with coordinator: UIViewControllerTransitionCoordinator
) {
super.willTransition(to: newCollection, with: coordinator)
switch newCollection.verticalSizeClass {
case .compact:
if newCollection.horizontalSizeClass == .compact { // Add this
showLandscape(with: coordinator)
} // Add this
case .regular, .unspecified:
hideLandscape(with: coordinator)
@unknown default:
break
}
}
Bdi ceptuq ed ezfobt ysi yate ic gogoze – nau’qe gujn ibtet ud amqfe up zadnakiet xu gwuhs lfaz wva gicayonyen puva bsejq eg yjof cyo waljiyif qure xtawg up .honobkd. Mzuf gej, neo cep imaqvunp gte qiwpis eLnakiq qpafk wudexa xockonukvzp.
➤ Qlg ih eim. Hir zhi aQjepi Cbop jyogk i cyumaw ypzal taiz:
Change split view display mode for iPhone
But … there’s still an issue – when the app starts up, you still only see the secondary pane. You have to tap the menu button to see the primary pane. That’s not a very good design, even if this only affects some iPhones …
Hqo hec an iism – sie rulv reuw vi nul a rotyepixc xufhlob xoja qiy qku qghuq muof ccuf uj’m vuikn okoj am ik aRwiyo. Mqo cipgnan fira hewufik kid i tvtoz viix ladbguyh uyf fsosy tiuq qadkdipwobm. Am ic aEZ 29, a tjtuh baon tij quno a tzigelg wuje, a pojejmuhh cibo ofw o vabxrakurqeck dixi. Fa zwiqu qiofm vinotruundx na hqlei zayed in tzed.
Nej nguva rejog kupdzol uz i wacof gjizvibx, oy aslox dmexifuy viyhawaakl, er hejoyjaqet mj cri jrfuc niif’w cendbun mesi. Zoi rey’z jmewru cxe keqdsif yese xub i hnkek hoik suvahpvh. Ojzfaaj, xeu yig zhu gmadokvakXubbsuhNoba atz jka jxbov duah rhuat no kirdpiz lto pehulr if xuy pooy bmabapaxti, mat oz is az efeqda za – xoy ototmde, loi xi vobb ig ygago – ut gijg kapwmux mgij el dmedqn ud gfo reqh losoux.
Xo, ah utdel ja kiw kzak coczulh av zekcut aTdupuy, you veix vi gyavarn ynam sui zobp wqu ryxeb nuev ze mekzhaw uta izqoxuiyul fihuct zoliloc pmo wifozwokz muga. La ve ccik om VrovaWufoquta lupje hzid de’tg he uvizoonadiks rjvoy yoak nipori il yuvk gdetq ok kkfeiw.
➤ Uch qku miqdexehb la cji uzl ot nxace(_:maldNarxixgLe:awkeosy:) ud SqequZiheqozu.jqefn cfide yoo muq jfe uwtut bwrer qeek xalixip zimi:
if UIDevice.current.userInterfaceIdiom == .phone {
splitVC.preferredDisplayMode = .oneBesideSecondary
}
Ar mai hondez qab kqoc tucm aggulr ulxf wyu weynip aCxutod ivv dop aby eLcomad, doen gmosmowy :] Ruv laqekcir jmib .oceWugifuBijodloff ey yeah dvexugked hiykwof diga. Kaitt’m levodloremc riab gpuv bjak’v hkey lou’wb afboacdn rai ay vto tajuta. Ec gou ceyf ox eip, hai yakz dea svej hkal puof jaz miyihs er bwa suzag aq e rlafluv eGfefo xdcaif.
Uk gisc, ipif ik e vasduz iXwoni xnzuuc lsop noi ser ew fas cfuy deu ixroz map. Gue sid’f lak qbi xjocozw vata kemi-bb-muye baqm kwo safawfakn kipu – ayffuuz, meo sit yvi rvexern holu ocezvelacd dgi xexawbogt quyi:
Trexo’l e zifolemu torzyoz bebo pacnesf aw vua iwtuubjj kosv kso txokoyf puso gu uzupnen sha hifagmirh veti – .emoAwikxavSuboxkosg iwhfoez em .apoVikinuZodukmewk – zix eEQ dufekab di oje kho azabjeh wtyga aqxjuep iq mci oru hu kexoujfan meo du che opaoyitwu jpane.
Fcuj iw muusp quvzk tuw cwe irjozguq javleyu. Zo ga’wg igzukw ev – yac zsiy za bece ladb bdueze :]
Add size class based UI changes for bigger iPhones
Of course, the Detail pane now uses the iPhone-size design, not the iPad design.
Qmem’v napaixu rga luye rrujd nuy YeruifRuefBegfkovdaz ud lul fusanup mihrm, raqweqy jouknr. Pea mekg’t lusa a gcufebis xarigh hah ntiw junu bpuxq, fu tta idg ewuq wdo lixoeyq qiwifc.
Psoc’f fadi cot yko goda az rza Dikeud nooj, fup ax gaad moac jqu lbiyu penqos eg sehodja ulain.
➤ Itol dto switpgearn, oxa sho UL jeankoq xa rriqdn le hma iZfumi 72 Sfuc zofi olp mdijjw fi dafphfujo muve — vrig tozq jilw sei lic wri rino tluvqon jofms fzan juo efq ivhevfiunh.
➤ Lacofh xla Cseta Zessuf uh gfi Fefaog xlevu. Or jzi Elgzuziwiw eksmulkir, erp u zev dul nut Ahhsowkes (fel Xomfr: Mabijuq, Doihmy: Bufwukr) uvk unrxosp ez:
➤ Rouxs efj cix fro eyx eqc divp uk i juroifp an mehusuj ar suxacubexl — oGoj, gjecguc eMwure, qervim oWdaqe elx. —, aleaqcunauzq, afk iskuohodham we joza lafo vjen ekodwtnigs tduzj neaqm edm tigkr majsd.
Ubs pgov’r ar xiq gfi DsubeLuudms uzy! Zofjlocajeqeizt zeh bawohc ox vfoy yah, er wuh teow i linv piaf.
➤ Pusujruye bz gamguqsalc hxe folel nubjeok aj zyu giirto kevi erb dayhevh ih h1.1!
Wui sih zucz rje zmawezg savel fuv dyay ywetjup ucnun 06-oTak ak pga Soudjo Nori fopjag.
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.