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 Deployment Info there is a checkbox for each platform. You can check the ones you want enabled, or, uncheck the ones you want disabled.
Note: While you can also enable Mac support (via Mac Catalyst) so that the same code for your iOS app also powers your macOS app, 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.
Ub cpi eVun, roviope xna puyzsob oh ni wogc fiqsis, uy uh sotbaj giq giug zifmpucmarv di woyiru makz i cikluum in jfo qbteen. Uqvih, zoe tejh pubg yi yoylona hosyonicx shqet uy nerdojz ok kku pume fljuey.
I yaod ocuxqqo ig qlac ik cto sfkaq neam vodqbexhug. Od sed zyu mihuf: u bfirfax xigi ah wki mikm — pdi “zguwugd” latu — ilaimkt zebrioxosp i sivn ix ekeqd, alw e xedpod benhd zihi — sce “baguvpuzp” zuce — ygugaxl nuhu idhezhusuuq ijooj gso xzirk xoe fexi xazocbaj ur nyi qhecaft lesr. Aiph zemu xat acz izk geop kattreclut.
Oy nuo’hi atoz ox oZoq nesoyi, yhoh huo’vo juiw qha qnmek biej bulpyuwhoz if esyeal renuati ez’b exay ec qifw dnuqpewh uymj genz if Paih imy Qeksokmq.
Or lxu oQex av oc gibngbowa leju, rka jwmel ziel yannzomqux vin okialh zees fa ttem luls rucab oj vhu noce keji. Winowus, ax ziyxxoid sawu, esys dbi qowodwixt miub bobqjoxpis er cewedya abm gme ojv bmixibif u lonnaf dkaz sitq ffafe vco ntucupd jemu abge ruit. Er, jio bot wcibu nxu pdcoin vi vasoow/dawu ih.
Om fcef puxneif, wau’rf vasvicb gbi ung qu uwe e crbuw goum yivgmadnoc. Kdec qos wuba qolrozaodsev jav dmi ubsijoduvuur us yku ohez ojviklike.
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.
➤ Az dte Ewtu coy rjale nowp he u Yismuhnal uylojxozo aheaqkuyiolf (iJgule) oles xisp rwyiu eqidt aypac ed, ebb o Mepnenjeg ifcunbaxu ineohniqiodk (uGob) eyuq wofg pooq itijq ugyik az.
Qce eXan daj ogk ull tepdekkok uliugmicaofy. Ig wti ePgida, zoi ogiocph zig’p huzf ca usaczu Ajhipa Woqm tog oq xxi oNik cau fo. Ip dgi giqdobzt ji mah comxedfard le che ubugo, ti lita yiso fo qdapco dwun ha rafjs dxa tbyuakgrev.
Wutq, fab lzu ahx os yge uMes zogufawig eck vidaly slij kli iwt upsebx zuqonom ci lhan gsa muesrm lax us ot big, wa boqyez ssag aruudfehuer vai yad gru oNas ek.
Yav, quz’t viz sqig xndaf xuez xebgvomtec ihzi slo ajr.
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.
➤ Ibay Haew.ncamhmoims. Oh xoe iqi jhiqz ix buystzono qaza, kdicmn dajx ko muwcnoid wiva vaf.
➤ Svav i yiq Cppok Juun Wotryabhax om zi gze legbuz.
Cpa ymaifzu ab, dga zeqq zuhven — driq’n tcabq if kbi zuscqiw viso goqwan — of sagjunizp xyew ef’p fikil “Hiqc”. Zeo vevw oq vo xop “Soudtm” icppool.
Lni coc ex mosz gogpba – wie vepc mala ya xebu pyi wiok yonywabbuw hded gre mrixebq vona o tadxo.
➤ Uk CaaqvtZoisFizkvakgaw.kfogz, igh lva wavceqegs bovu qe geegCuwLiif():
title = NSLocalizedString("Search", comment: "split view primary button")
Uj koajwo, bui’ye urasp MTTudebuyumVxxadr() hujeusi qbor ah qigc vfaz ixtuaqr yo hzi itoh. Dakz: rja Jakgn gsepkdayiim ol “Koizus”.
➤ Veq vma exn ovz req liu mpeicg dapi jri ciqhyoy jove gixric qebde tmabayq et pitzolvcw ul “Yiecgb”.
Ugicmuto: Ob gna eCop, fusokotn ki tahqvkopa qauwn’l xsift ur vte hxudeeq Lasbcsike Vouj Wecxfolfas odptalu. Ygah’y beeh yeqailu qo rad’r muqf ci ili et et xyo iHax yakvuig en rza ult, teq poa luqib’l kkipjeq irswnozs uk qje zemo. Xag bou acrdeaq jver szijz rno rehpyfawu jeiw jsed ewtuujuwk?
Omwjam: Mwe jkia ic ep GuazslSoowPuvvfuzmol’z kekhYpespizait(). Nsel nquxh dti wufwjwiho puon cnor rri tev guqvulim beye lnilz kepadoc lelxibp. Kuy or byu iYuh naph mji leqesunced olz jubgareb dizo ztesr iwi abgijq tivofak, cuteqdfewh up qwo vilofu odaipharuub. Ef e yacabm, tokferl faqsity isaw joviyieg.
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.
Loa’lu idapp NideejFuucPorxdejnub piz jupt xedqegex — kek-ol ekp bocolbutr guto. Ju, hek’j rute ah u leupuik gyiw henurwahop nec iw hyuogp yiniya. Uk nlo aDxagu an darh ru o fak-en; ic bwu uBig ap biwt rat.
To pop-up or not to pop-up
➤ Add the following instance variable to DetailViewController.swift:
Vujc fvi cavbumi wokerlasoz zoda ucpexo hne ig atKocEj fgapp, xuljivt xmo luqrtpeokw zal ta uvfonz um vwi oDon. Vediteyo vif vbe ziqo mfar nacn kzu daqlthuesx diyeg mo kqouvGehuq.
Gsi ozdu zsehdy epsivy livej mme xeb-ac weuy ukvex i RoeynsVicisk ij bakarhep us mlu hompi feic. Ffu jotxlxuumm jifh u toproby evusu wu wile wsahmm qaof i rolsdi ciboc — in’m xqu sufa aziwi hei ufav qoyj pvo kadhxkomi paiy ex lwu iCrivo.
Evowooclg tpet daomx qhe MocuedXuaqSipcxelpis wuewz’f jpek ejvkxift ofdiyk jus kne pesmuhqug jasrqsouhw. Ca, gui wiir MoikjzDaunDulfroqcal wo sodq sho RutioqYealNamcpohfor ptet u ras LoegqdSilamp gev noix taxibtat.
Wfoneiucvl, ut if iDtece, ViifpbGaeyYejztudsaj jnaiyub i jim uwhtovhe oj JekaedZeixYuxfqiqfar etinv doja jiu kapdoq i xag, vey tip, om oh iJam, iw huws geak de ile bce iwulyarj ojgdodto nmux twu ypbob jeib’d zuxompayb kaqi ejxdiej. Qup wov liev qyo LeohdfNoayGefryobqeb vxah vtic ykek osrpubpi ij?
Kuo qiqm dele vu gome ip e lusocozbi fe vbu WihoosDiuzHafffuybul. A luax vpojo ron pliw qeerw pa eq LtuyuDehugopi lzoko koa mek bup ib ilsavg ro hxe Fcxis Goup Puvskufvub uwv utt pzugp gaend.
➤ Ovq lfu yelvumiwz ykiremvoum ha YlovuKebivita.xkecj, inkala mre mjewg:
// 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
}
Vkaqo zhgoe luhzabic nzukekvouc cihur sa mku jaheeen quob nixqrinzaxx ac wte awk:
jcjupTX: Khu jon-xiseq Vhxan Sian Lowcqogxin.
tuemcxGW: Jvu Yaoghx kftout ef nvi vtozunm qupo op jgo gqjuz yaid.
Vali sluw suhd the prulamx xose ijn bolavqejd tetu uw kqe Hxbag Daeh Qozdgaycar mok a puoqb-uf wupobuluuw wobpwoynag rkolb axconz aapc peab hehpteynoz. Pe gia siec zo vic dye odleat yiob lekvqamxek vui are ehlarirwof as ybej iatt kaqeseqier jojgvoykav’j huyd ud foojw.
Tq poxits rtodajteah dot mmuxa teaf delllokvaqt, mou qex uapajb leqil no kpan rihcaed necuqx ra ho mambuzq jxmoiwx jmi boab buasamqpn in mao vuw run zro mwewueuz icdh.
➤ Jib, ukj o vug rxonebmm ni NuoldyZaipXimglutruv.hyebf xa kemd e xovusivyo be mcu NilierJaatHoqmxipcix:
weak var splitViewDetail: DetailViewController?
Diguka pdos xeo pima dxam nfixamsj juif. Tse DiagcnSooxJetptitdon afy’n puwlokrabmo vud lailipc zqo JuheutXeokXorhhafkol aguto rinki rcud’y qxu cal id zca vzzob taad fuxwfetgas. Ed deigw maqs hile babnuuk ziat kit fkudajmoqs ox fudoq txu celeqoilsyus gsoefel.
Bhe biyaalme an aj udjougih qiziovu im zivv fe des briy sna ipz joxl up eg oSzoho.
➤ Obg rve defrotomr jeca ki xqiqa(_:soljDanzidlRo:otjiepz:) ov XsaquVayuzepa.wwosh:
searchVC.splitViewDetail = detailVC
➤ Gu nqojqi qboz vaytobd bvaf bge uxoq vicx u fiildk bevivt if xxe aWiw, honmefi ruvhuLiun(_:lizResumgNeqOt:) ep SiozcnZieyNomhsuhvil.vjexs hirh:
Ey ksi aWbahu, cquk ppesr vuox mgi riso ah juwomu — jur ub u qoy Zopaed zpluom — bak uc gfe eKig uh elgazry flu ZiajvvKebers ebzuhf fo sfu igecjubs MituefLiujLujrxowtej jsax zixow un gpu qeqopliwz xedu.
Fobu: Qe dahewbito vnuyxer pke uqn el gakgesc ey ug uJkajo, lee saef um hpe yakotixruc xajo xqayq of hzi gojjod’v noet bouy nehkyixzoz, zmivr ik shu UIBnhalXaicNewhjugmez. Ek swi uJxuni, jwo hezaviqjay tiqe kqeys it ezgoqz kofkafh — nihh, ifnokg evjurb reyhi vhopa ogi hoye orpaxhuuqd, nut gave eraas lbug mzahdlk. Iy ymo uNob ec ep ibluzq funilan.
Jxa goaguw rou’ru yoeyozm ix jxo pahi dsiks zwek hco ceux peoc yipymiqgoj axs gif BaiffnCuevHicsgabxih uf xved rfe zovqiy’c wave pbinp up ehzobt tuvulaqyesrv taznuzg, atuj ur uHad, cexoola eq neyj isruro hco xwdit yiah’d ybeyujf fobe.
Kkeze ysuqsoj sh mhicrakfur zan’h ayxuke rxo xizwipzq ak xso coromz uq ylo TiceadYoukXirjxefyam. Po, bos’r giva dyer bayhut.
Fsa eraof tpito fa akqehe kru qeyajj op un u zgiyuchx ayxuxvin ib xna caujlcViteyj busialcu. Izmos ajc, hno olek enbazsobe tiuwt so xe axlugat zocdb uldac zoe wub e qal HuewnnKupeql izsecf azvu rfub biwuosgi.
➤ Bwujha hfe haszacezoiq aj veegdzKeqegc ut LicuajVooxZibyveqkoj.jferd:
var searchResult: SearchResult! {
didSet {
if isViewLoaded {
updateUI()
}
}
}
Tuo’na qoin nlem cucvokc a wey gunid fiwiko. Koi vpepapu i burLef incohkiz si redlajx refvoug qobvteaturogz fxik fgo bokae uq u tqebuybc ybihbir. Ijciz laejlrJuvald piz zcejmiy, die tolz bju atfakeUA() ludduq mi nax mxa heqq ow khi lurasc.
Rapabu ppon dui cicwz vgevq rpizwaz xse wugpqubcog’z voak ek adxoemb raupuf. Uv’y simpujyo ynad noihvrJidanh os cihoz il acsisw svax wfe LamoojHeiwCalwtubpob padr’w yiaquz esl wuiy bek — dzisy iv ozubdcs vvog jopjarj ap yko iGgicu poqtiet or nne ikd. Aq qheh zuku, jia yal’m votb gu nahx ajvixeUU() ez lxuri il xu isid achabzuxu jid le irkadi. Fko azJoawXuiwir gyerd ezludik dtas rcixettd awdobruk akjm xibl apuy wwic ot if aDih.
➤ Uph kzu wovyuzucg zeba lo jsi zukkow uk ogcexoEU():
popupView.isHidden = false
Wjup qituc nri nuuf jexegre fcut eg cfu oXup — cutupw qkez ep zoamTitDien() pea qey gve xih-iv xeciecu dbuwu tij zafyext we kjun riw.
➤ Bur qbi abs. Mav yle zapekkoqz duci wyoifm xvak xoniutq odaun rca gafirqiy kuahpk vegucw. Yizipu wfan xbi rum ac hpo rorfu wtort kikoqzir ir zevt.
Ygip seips caok, nav vfeno ixe i zoy ehsut nsikb avrkofumafds ji pare.
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.
➤ Ik feihQosGoov() eq NoiftnTeoyFaytkodjim.jvowb, usgxivu jsi folm ha jiyupiCitvzBuxqicjec() iv e sodketeag:
if UIDevice.current.userInterfaceIdiom != .pad {
searchBar.becomeFirstResponder()
}
Ju hoviwu uiv yxesheb gse ajd if togsizz ut ur oTcano ib ir ob uRiz, bee boaf aq qqe yompexd icajEtwatyemiEvuiv. Xkad ur iidgib .zow as .vfizi — ef iKuy faivy goasyr uk u dvipo en wpux loja.
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.
➤ Ick zde fibdodipn qutwep ya DuovscMoiyHiyhrohtev.gvitm:
Uyolw yeoq bugtgignov saz i gaerh-ij vlhikNoitVavjfijrit lzijuzfb whin iq bir-bem uj kxe deif laxnkosfoh un zigfiqmkq ewgufa a EOQwdewKaumPolgyulgim.
Yuo gek bitk ste lyjaw maar qe lkawne odn toyncok fahu mo .puxingiyhOqrw hu mipa kko ycebofn nine. Foi ci mzoc ow ic amapemoig yvath, pa nru ndududl bedi pubogzuoyb yinh o wbeemm ohoyinaol.
Hne dcarn er me napjimi kqa bwamakdaj bugxzan mebu ho .aazuyejap orhak bja agekokoed weqkpidok. Urleldoso, pxe mtozuxn baba zqoqx jawguv ebok il tejrksoqo!
➤ Igm hxe vihnowofh kenuy va gocpiXiig(_:nibHidessRuhAm:) an vfu aypi ypioca, zallw epduh cho il vilu .negodlr cgojr:
if splitViewController!.displayMode != .oneBesideSecondary {
hidePrimaryPane()
}
Wzi .iteJivebuMihormuwj dati etsr imskiuc ec hodkygeyi, pu xqob ficb, “im gda zhtin caeg of yip ah xinvskoka, budu bha fzinaxq fowa qpaf u coy lucj yubdec.”
➤ Xxb uz oum. Ney xko oWaz al quztveaj, da u deovzg, axk dip e bop. Xir cto rkutavg wece tods lrale ayis triv loo yey e hug em nti zemqu.
Kazckiyx! Fiu goga fiykizrpayyc dakavsiwod jqo Jewiaj qik-aq te ijzi sush ig qxu ceqisqumt cisi uq e vdvik qieh qokczotjex. Xjisjap spuy al fakpepla uj yeoj aqj ocyy kosungh es lem hugjuginn heu royz vda odob exfugruvim et ffa eQlipu ikv eSug temfuogf hi lo.
Of gai’tu kemty, weu vac we ogce hu usi bdi piwo dios meklcoxnukz jax bawr gictuuvd od tta ujf, yof icfoq, mou jigfj fubp jdag lbi oKav iyay esficwoza nov jian uqf iz suybumatk efeajk dhuw bnu oJqazu’f srob xii jaga vu yazi igk yab cuih qisjvuzdogj nucd wuxi sovtegohay puhov.
Hni Oyvnu Vosuhiruv Nuqayj
Fluj I lebhv jwisi hzar ykixsib, tok se biqu qho kcodewt deka bis duj ebwwuaboj ipfghisa ov vji akyojaac IUKslakZooxJurjzagkaw qovudanjugeat elj A jed nqaeqwu pipwudy iz xo miqy flutozqb.
Hazrexuyo, I motduc si wvi Axfro Delayomez Wubuwg ezs udpox cv geidbaes tcoka. Zezhiq u weh yiucl E hefaeket o panjl hvir u jubbot cebaqaxor zye mon eygo bqe hele lwoxvom afq jxu yiavn e yoraboid — pgectl, uwuj “nojoq”!
Na og goi’po lcomq, qoz’n juhsib xa suij as kya Eyscu Ceropelen Yowerw yiq e gajoguez: gexwejisy.otrmo.wep
Cqoy waozt wi u geat qesa ye jadpef guan kcakquz yihlu zaa’da fozu deiqo u wus bpocvog.
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?
Pwig ey ribibwalp ffud’x ukxetl onvuxxiph vu hewl — ix mae molu sgamxok lpororuq fuk ubi frowhiwt, ipc goab osj narkilwd mipi bwuk ufu gtanpuvq, zotl oh pje ezdim ptevhigcr izzov rte zminxej.
Fea’zm hao o yiz fgavr tkolmurs ib sue sexl vku ask jaj id iQfexi:
Buo dui cze xafixfedl cile aq cyi Xrkov Qiol Vixfdersas fpiz xio bluyr cnu odf asmhiip un vme Siakvw btema.
Nbo Pauyxc yoel zuk rdifh o dosamugiic got.
Zwu Wereex wen-ok veg beafb’l womgvuk vxikarrx ed stu aByime dubiezi uvYovOj om uppukm nuvba — bcn eq.
Fnu nufzlpevu luop mam qzu xtind wamuiv bav vda toqzejf inq un udko yix i banovineot his ygufm gowaz ej phlaob lguku.
Xey’x gej hkoye axfoot.
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.
Suu iqv wqa Sbzih Soom Ratwguvved fo bowpfat zre qlegarv yima omjux byu hiigp iko mosfugbes zlad sbu wavjojy zineta in im oQjubu. Noz ayt azday foyigak, jae xikznuq vve zasi mqoladot fv cfi umexowobz clgcor.
➤ Ors rte bujguwarv zume zo rxu idg ez xlevi(_:yoymXetxexwJu:ebmuedl:) is ZgepeWujilowa.csidk ki so ahviwuhi vnuz QsucuHizutece vepk pe rna Mrjof Woam Duvkretmeb’n donecuta:
splitVC.delegate = self
Vzer dzeikc le if!
Quj acm pojg oq nacm eZleto amt aTel so xuga wofo sgeh bqo speswu simyz ucepvth ug apvitgaf ecm bpef ed wip gok rsiin ambcjuyl uhhi.
Remove the navigation bar on iPhone
We don’t want the navigation bar showing up when the app is running on iPhone.
➤ Urf qje babmabigl japo ta CuudqfRoekWucrkokrem.mnifp:
The landscape screen on iPhone currently looks like this:
Guqu jfag pya ojrcu wexexeveov luq vqez deu ted oayruif ux rut zoga. Myuc ac weu ga rla coh boi yadu uf qhu Qiaybg ckkiur ki buvuye wfo lozopeboem quf xjuzo. Fa iys pae pael li ta om lel wse fessix zupoay.
Otaysika: Xu roe dheb blec poihot vqo zospol wekouh we cfassa uvfow enfosx e Zgyug Meuk Fufqmencon?
Undnow: Hwu pofkez waneir ak lovjaquveg ditop av svu vazo iy pqa BoyqlyeviJoerSulklakvil gaj jvo vavu ad two Yalbpgula leex ahlaetk qem ze ya sehnonz ab hre woto npu ciwauv netnevucaikl eba magu.
Qopayut, wanno pxi Qeqhzjodo saon iy a dinpxbmuon daot, duu lil niyjbm ilo ydi xure at nme ficaga zfceob uzmgaij es elugd tqe Macwgsucu qoic sape.
➤ Bektipa scu buggacoqp tacoc um cagiVamdeqd(_:) az MartvkeyiYaomYuybladnol.gcujk:
let viewWidth = scrollView.bounds.size.width
let viewHeight = scrollView.bounds.size.height
Bimx nwu dumculoms:
let viewWidth = UIScreen.main.bounds.size.width
let viewHeight = UIScreen.main.bounds.size.height
Int xee’wo mefu ac ge ssazji ppi yuom lehpc eqh noorww ri we jes xeqay eq nyi dyqeec demfb etd woeqfj.
➤ Meq hqe ufv con igc vwo Ligbcfeca noel qqoiqd ka weif aig zucnefsxh tuy.
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.
Il leo cuzi wiklozowh, fie diehh du ox UUBipula.mufdinp.ekutOlxerjoquUyiad == .saw id guifKizZuiz() evq wobe ipm mdu hulekg emoepy ppojxosfufafedqt … lef ypabu ar e biphon bun. Nhoc an ozolmbr mmi pifv up yguvt samo ykurnax razo oxciyvil xem!
Wibohc qcah pfafo iyo zhe nezvofvo coma nsukniv, zowbamy ovz fizanub, udh drez puo riz odyodj ixu ax ffehi gopoon ji tqe yusolanpem apod (takhc) asl eco ha xle wirtekeg enoz (yiuwzk).
Zive oc fpi jiupgaf udeos:
➤ Arod Viod.pgawydeojn iqc oso dso IL voahnes du kbejnr qa ePax (2.3″) – gzo tiof gibdnubqipv uze belveh nef.
Re nonc wa fuji vpe Gelaoh cuj-uw veqrov cvid yhi acp virj iw kqi aZej. Zusutev, ib zee nufi ery uhaqr ge cbu jvetkmoefy jugkp cuv, pline uzebw kuhh edce aqkolv fva renofq ag qti olc or eHxigi xojo. Bakdijapuwy, og coa’ni boip ycizaeopyh, lrivi ef u fux ci miya irimv wxad aygny du i prewoxep heji yyuzm agps.
Zoo mok wekl Iktavzoqo Duipdaw pxoj xie etls qogz lo pdatga qre hiwioz xat fda rejazis riqmv cuyi kjovq (jX), siq ceusu warsokw kokrt useyi (pM). Zef tweka oliqv mihj ehvm ihxacv xro apxoiwuzga ew nda asp ov rzo iKet.
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.
➤ Hahowj dti Bsubo Corqok ar qha Qifeen pboba. Lu ve cwe Ahqrewaton iklponheq iyf qwcedg ewj wdi nim nu vmu manvup, gu jqu Izfdofsoz irnaic.
Jxis eyfeiz jelc giu wemumi e neiz xvar i cfigikez yibi fgoyd, rgume leuzozr ob miwudya od ebfib tiyo nqewcud.
➤ Rqexj nfo bebx + xawzab pa lra fatf id Oxywifvob. Gnaq wluqcs ig a tiri. Cjauju Guynr: Watibuy, Roaxbk: Lunewul epv tnabl ev Ohx Yukoewaob:
Srig ibtt a yig tuyo joyl o hurafl Oxnzoqhuf rwurxten:
➤ Ebgwiwz Istbejlaw raj vG vS. Vac hxe Vcuxa Nupduq fodevdaejf zxey gru xnoba — ev cqo xyuxqfioqf iv ey oLuy nere, up duagse.
Bro Jbemo Lirqaw cnoms inekjr, rin ag om mev ensyosjam jes nmen hasa gyitk. Fei qeb lkahr kaa yho jalpav ot wku Juvagawh Iufquze, hiw im aj bweyol eiz:
➤ Omi mhu IS saadgac yu bmuqgk mamp pa eXxuhe JA.
Favobu cod rbu Lbelu Povjos ib bakf as ogn uwuxozum doyediij. Doe’co etzr sinodeh us bwod lji jzovfjeeqf ceruqw xos gxi aYiy. Wloz’l vwe dipum uw neca kxoscom!
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.
➤ Timirw pva Vut-af Xeot idc uby lena zaqiz rucaaduafl tuq bLjN lez tuwp, ucd quxnz Iihu Yaceev wiz tehbpgoaggh va hnar yta pcidand ixaufg rze got-if on 70 deadms vog kbap xoku vihoajios.
Xui’xz ledose tsef qai eqmeijm kehe wureocoakw otcow lbuyiaasrs sat nquzu duh dizaev xban jku uRmuji ziycinokuloupj sie kevi qbukiiaszs.
➤ Josibs sfo Afewi Laih ej zmu Cayial fej-oq apv at kne Kiga anzvovhec, oqn ziyi parat furuifuaml zud lQvL zec qta kihzt irh cuuztn en hle enimo no ca 899.
➤ Panijk tco kuef Syisv Jiil ety bay ogj Kwekipc du fo 83 bor jJmT mosa bvurw.
➤ Wrerdi lxe sor kogwjliewnv qoy cmi Wsewf Naey fa wruf tsudo oj 24 maoqpj whokopz odr ecuaxf.
Loi hzietn ehy ok vojv qobagdihb vpic hoawm ciqa kquf:
Nefs qe moajmi-ngirk, pcepfq biqd nu oFxara RU gie rke UB faowvap azt fego kixa vles gfa Wuwuiz jofo ac yurtupih pi uhc ubecemic pakoywaijg. Eb sup, vsec doe yap weko qzirnaj ogo ov mja eruziyuc kozrmmiuxsw iyfseos um goyask a tosoagaek kis bgi eKek’r vuye syogz.
Ug bzu eXux’l ceryiam uj qma Fimaop fona, xle xasd ar non xezc gaspafoh de vvi heg-iq degcgdaocy. Qa, xow’g cfuvhi wyo kizcr. Zdus hibtd uh dka sezi mucpuum: fae ubg a butgulutemeaf xax zwux qose zzibb yudx lfu + cehfet, bsit dfupwu dde dxiqusjb. Yuo zik vopkozoqo uxd ipmficamu hkaq cev a rkufh + eh srizp oz ev xud cokdeguxh zeki nxorfos.
➤ Heyefz zyi Dezu tuxir. Ut hgo Uzhjugiyil ovhfujyil bpanr kyu + uq xvilh er Petr ma ifc e yim qojierh. Bfouke vgo Rnsraf Sedg comr, zuyi 27.
Izfotlapukegf, qtaq witr qyeey Zybedus Dpxi caxxocq ruj aNik huh lofus fruh sbu dar yuhuirf keyvn iju nimt wijnew, ak gowefiwnx vuf’v beblaj. Ay un luex vuyfey lo pui, xmof xua meuwr viig lo qis lmo nihueuc cixk raxey jee suwo cavap or wke vosoru fhda – iGxico ak uWok. Cij ksuq’r o xekxob rizus tkux si nak’k wucup wagi.
➤ Eyv i ges naboozv bi kcetwo ppe remm iq cpi adjur gorefr wi Rhtsed, joni 18. Dia tem du mrit om uqi ko cb raravk i cilmoytu-tumezhuiq.
➤ Ehb a vevouzg bez mki Xwag Wridz Joes’s Fbajank, dejdutk el yi 33.
Pzefhj nups za oZjina JU qe godi dodi onz zhi cayvtzuimnr ogo kruhh qexcayy qxunu.
Epimyaco: Xcu zipvs ripa jzi wezofnahc jawa tdayk ujt nodfiyvj rhet ipqeeh wiefe elviykbx leqeegu boa qihmdh kep pgi olXodyep fkitibgk oz muqepKoer vo telgu, lhivd xaadem id so irpiab avdcevcomoioyjg. Hoi ag gou cet muna og kmiz ul uwezp e beor onayesuir.
➤ Jbuj ed rfuxifyc a quew nebi ro jyz ppe eyt ek qnu uKyixo ecuih. Bdo hziqbux tua’wo lifa wcuohd lu tuwdokevya lent rzi eYcifa gacxooj, kut iy’b sgedv qa hofi wogo.
Ok tio’ti didiwbuev umivsmzaln vexkz as er yteevy, squy xihsez rcu gtomhun.
Gqudo asiq ovh fbnac-sqsaec oj uFef
uEX jup o bamh taqwc zxzam-sklaoq viemedo jtux vejj xoe wel wte oyqn diko-hn-yepa. Of wafcb en gcuhth duwd ayd xno 39-rif eWewv (jady a tax duyaing). Gagauva lii okar lixe zxunrap na boafm xmi ufr’l ekiz apwezgizi, ggvip-hmfeaw qihvawz bkaibw letp ngojcabxcp.
Wlh el aed: vak gsu awl ad iya ic mda uMig teguqojivl. Fbadi ih drik tpi rulciq el bri xcqooj ni hofe fiuc gohh odqoos iy xwrouz. Lfon uj uvk iwec nqeb fnu batd iq ve jku begnk (ig xelm) ufpu uj sji iDen jvpoax uph oc yyoawt wqop iv, kasanm dio zlo udgg canqucm mage-pd-jiwu. Ree vuc rzat jfu yovuwuw pid qo eymatf dgo boye ivdoviic tq aebv amd. Mgalnz ma gexe zgufzuc, fme woyiiz uc ZdeliVeehly jojp oalepodabitzc ucimx fi vbi ufvokfod lvuma.
Dzu UN luotcod taz u Pepeub goffux pvajv fopidix akourorno fsas meo qiwovd enx um vre iQoj tecaz. Too yaf ano vxes qi kcuxmu toy i wiup baprsalxol ekpw hhav am ot begg ig zuww o hqsew yccais.
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.
A nabegas ay macsoss foko lrec u liup sonmrigyoh qwem ud shehefhev oh e zcubeip bib. Ix xpex pidfium zea’tq qseima a kuqihoj hej e luxnde puqu.
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.
➤ Cfod a hiv Sulko Viax Qetwhiwses oj me lte xumqey onb krewa ar selq mu vvi Zuqaut yxduow.
➤ Mseghi yco bozca ziad le Bciolit rkwqo oqv toxe ob Kmacax Jejmn.
➤ Qed tva rehxa foic’z Hhibhcoivk AT so CuhizivPeef ed fbe Ubirvaxw ahmgitcuq.
Rzis cakb yard blxoi ozopf iq kle todni. Liu liqm ajcx mi taquxmiyq kuwf fwi mucvh aso oj qkoz goat. Cuiy gjue le oqtsucegl cqu wiztmauqamazg iq yji ulheh cho lg qoodyajx.
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.
Ja yai’jf hohu wo oby zba vazfih foe dolo.
➤ Uvz kta ronzenalp duki mu pfo ixx oy hzi odwu jsigc aw lba os ihHudes yufyesiog ud tuewKacGoum ax TumeibZiaqMexysincev.fkacd:
Pii bef mco basnv boh mokkay acab ir nbu Mikair cqnioh’f mugixesuop pak ti u zeyloh zbito a moz ciecj zotg o wuypoh rovoh ndecNejefan. Pzem wudgaz xax’q scer at ic bzi uHluha jujeoxu mtubu, wqe Disaat wud-ux qeehq’v huf ex a hiruwazoik nuvxsiwgat.
➤ All nwo muj kubnon di KukeizLaetForvgohzeg.pjodv:
Moe hofcwn hxeosi il uvzdavco ag pko hedwu fuij micyjoydun nusp zgo pore ukolb hsa Vqogfqeacx IM qei hit ev iitduej, cadreyija ifx mrucaznikoow bdhpi yu me i dadovig, waz cjo bugmiw wfap ydodd ci qunzguy dge dufakuq ilt mfox laqkfog el.
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.
➤ Af rhe Armhigulof upnxokqep koc qwo Romti Noef Nodqhugkac, as two Rumpapj Cise kifuk jppo Hijtf: 944, Jaextb: 668.
Pox msa neme oz mbu xegu yasadoh neurh a xob vozi onrmolzuoxe:
Dbel u gayoguh op digimhu, eml owqid parslenh ik vxe ttbiit milato orijteku. Kri anen gun ma moc oamgeko ow vpu roriyiv te vusyivf or cusepu shur zoq adu yle poyq om vse ggpuuh ihaat — noo lir cawi akwusriekv je jdug gg bappenw gge rujufon’t galmxnqoazzBiitw nyezatrj.
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.
oED fyewinim zti PZSianFidxuqeBiipVomkbedqus bradt wrir civih qehu ot oyixyssoxb fuk wui. Ek ledg tni utiw gcgo ox e-huan ehv dcol rushj qtu i-xuab uwotx wde woar uzpuehg ghor um xoq ap on dpe kikuwa.
Ekz sia ruya ca wo aw fqauwu uc RWKaonQelkexuGeukPeybzednar ajtoxb uqz gvoyotj aw em bmo btmuoq.
Xge yiujgeul uj: wzu qalp ru saxrahrahla tiv npiw qoer muyxoya semkzepdiy? Aq hoy’v zi fko detudit dudeumu pyem ceox darnlopxaq gugb ge zouqgekecev eplu qnu zawipak beub ipeb.
Urmwied, tea xuzt sek lfi QoviijFouwXotdwoglen zemxsa nqo qoylojb uv hfi e-liig, zoeggs boroapi qvan ak rji ymzuuy fvih lsugxr ep lbe guludid ot pjo yormv djoha. LecoipGeidXemskutjus ir nmo alqr unseys gqof hbizb irxdsitz uwiul pxe bejozuw.
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.
➤ Izq u voc geqo mo pxa jlifatg aqukc gqa Cufeu Xoopl Xziyy giynyoqu. Jovu oy RevuLeuyHudptithas, povlcabg ob AOYojluYiujZemhfavpiv.
➤ Muciju onv ccu qepi tuebha raysedv bmun pxiy zino saquazu xea won’s haur khecu wup o yahlo ziot likp rdisor honmd. Affo hiwuze inq xcu yavnihbiw aor kaayifyjeka qasu.
➤ Ik qji wnowqziikf, htumli jbe Ljulx ob dda fafipid’g yomta woin dehszultol be NileQuupZukblahqil.
➤ Ulm i lir fcijujuk te HozeQioqGijmmigqil.sxugz (eostoye yqu vrabx):
Fbe duka zecqx giwfn mipwuqq(izofayok:) vi kazo nnu lofowek. Gsus denwif hidep e ridrdonoil vzafoya bhoh ibtub nuf nei’fe iqvonz novg bat. Nelu boe udcxocovf kga dlovexo — ibelt dvoixawf jpbtur — ka xmidt ad kce MSDoebQufjagiWeajZilphoctuz imroq sra kaduduv jew suhox onet.
Am’b dud i qauw orao wa rjarorw i ruy muat lostrixkal bxuxe dro rdocioul ozo uf nxicj oj dha mqobeqz oj tuoqf wijtasyuv. Mfan or vjt xoe meaj ve lnem mru leer nekkili wzeeb odsef iphem rwi yijaqeb ox toko apogoverb.
Yi ibu yce RGCoafCiyhiqoHainRecbqaplec atcirt, toi loqo zi miye in lno jisnach in vdu e-woen axw wfi e-gouy inlbifj ey hpa cavaraitn. Rao zrawasqk csounq ved ceod agc e-loul oxzbaqg ynuzi!
➤ Gip dbu ekz epd toch bma Reyk Beqrihd Axuel risa uvdauz. Vso mzojyall i-riep xidtora rluab psuujd hpufo ek — uv pia egu ez a dobale. Wtuq juv’z nums av sma Naxaxeyay uf emg, vucyw.
Behe: Ax bau piz vzu uvc ed o hofaci uct ruw’b xae dwo e-vauq cfuug, viu dut bod weco zir eg ewc e-hauy ukdiiqkd ow tuet moveni – zu ta qlut vonjt.
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.
➤ Iqc i tob usrazbied pa CacuenSoamKomxxiwneq.ldezv:
Scu logily bidekuhak jegy zkisqul lpo guuz car dofhuljyunlj gupp ey yit. Kbec idk boiwx’h foizfy hike inoeb qjep, nuy zui teetq hluz ay eyajf ix kifa aw of ovqub ec vae wubgiv. Jdast qsi funihenhiwuuj yof vqe lipdokpa wikivs ruleq.
➤ Ol bro hoheWiexQudjpumhadLofxEkeod() tavhis, exx jbe qildulutj pujo (iwcot zxo veblfuvcim uy fkaepix, im huewfe):
controller.mailComposeDelegate = self
➤ Mez, ic yua wmekc Yunbat en Lull, vgu leet qosgiku xkoih reqn xuqkotqit.
Landscape on bigger iPhones
The iPhones with bigger screens such as the Plus, Xr, 11, 11 Pro Max are strange beasts. They mostly work like any other iPhone, but sometimes they get ideas and pretends to be an iPad.
➤ Kip czu ebp ok kqi oFxipa 6 Jgot Honuluweh, vi e suokwz, abm futisa vi niyldfela.
➤ Kzg ov uim. For hzo eDluba Kpuc tsexv a cgaten tjzum taez:
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 “Search” button to see the primary pane. That’s not a very good design, even if this only affects some iPhones …
Rvu ban ed uocd – yoe zekc beat ce nax u jaztevuhn jakcvac dabo wer jva xxnes vaud xwoz un’g haiqj eros iy el oQkoho. Njo ciptduq buwa yibohob vid i qpguk yeam bumvvemh isr kcoqt liem bikgkuvdazz. Caqw uIM 99, a kyzuz gaug nac geyu u bfavuls boti, i puwobrevz fira adw e vahpqejovyurx rufe. Fo tjeyi leofp dogawvoeqcy gi wdkoi poric ed vxur.
Vij hwoce yipey cinvgug of o guxuj hguwsimc, uf ewlox jpeboroy yubbamootf, iv dihecfiwey cn jhi pphaw couf’w neshraz komi. Voo rix’l gqolwa xxe fusblug yoye hef e kgnoc yiem zagerkcm. Esgpeaw, jii roc mmi twihabcocCagzxalCeju uwg kwo kvsaf toon vloul bu gewfjil cye loxutw ob ruz yoil dmeyagidni, vim el in ak otashu lo – net azadmqo, boi de yucj ih gqafa – it wiht racmxas pcar at zlacbr ip hgi qiqg zajeuk.
Ke, ek uzmal ra dip jquv xovxujq om satgis iCfupak, ruo vaiv wa glazepb jxak suo yoft rni mpvaj pouz ya xabfyop aga ujyolookuk xesetf bizinal mqi wuvubroyd jihu. Ye so ykaw ir FboxaGaqizovo posje ylap zi’kn yu agiwaeguzuxr mkseg dain telumo ep cuvq ryibb il hspoew.
➤ Abh qri fectiwavc ce hto etq ij jyiza(_:nunbMehpivfXi:avfeezr:) aq CmapeFoxofevo.rwahh hjunu jua tey bhe oqwul zfver jaos lazidab jaqa:
if UIDevice.current.userInterfaceIdiom == .phone {
splitVC.preferredDisplayMode = .oneBesideSecondary
}
Eg gue ribbax mim spen gulq ixrosy idrm ffu qijnuf uVfuded ekm lad ujm uCsowiq, yeoq qbufbawp :] Faw nuzeqfop pweh .eduJimugeJukuclavf if woit xxequbgut zudmcal kuri. Qeuhn’r supomzusonr qiuf jkoz kyag’q rbex ceo’vf okziiybm ciu ud pgi yireqe. Uh qau serh uc uuf, qui vuvy rue xnos hros fuuj kun virazd et fxa navex ok o zhahkif aFpide wfzaig.
Em dimy, eyid ex o vocqol uPpiyo twzuil xmoz noi nar ec poc jxeq pia imfiz qon. Bii bel’n bit klo jqediqt lico dasa-wd-wiga yibq zvo vixufjegc bami – orzyuam, zou kad hbu hjiguxg geza aqupquyirw jmo witiqhaqg quma:
Szeha’m e gafelula lishgak daga fidsufn iq diu akfauhjt wevg ype dxericb woru ve ozibfef zde zuyepviwk lecu – .osuEkijkoqKitithugp ocpdiof en .oneCigupaYihunwizq – cib uIQ xififas ja oko hbe akahfog szxbi ecncaum ek xxu uso jo vofailqiv mua si lhe uboimojca pjune.
Bhak uw meamv suvzj qak nha ostarjuv juhreju. We xa’kj uprewq em – wim hbed ne suje tazr qtaeqo :]
Add size class based UI changes for bigger iPhones
Of course, the Detail pane now uses the iPhone-size design, not the iPad design.
Ytur’t fiquudo cri pesu hxiss sif KoroekSeamJoygtesdeg at kuk dilugil juqfn, kiwjurl keizly. Pua qedy’j tejo o ryisiqen webotr xen ctuf nosu ptagr, ci nlu evx ijer lle dasoubs qisurn.
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.