: nil))
                self.present(alert, animated: true, completion: {  })
            }
        }
    }
}

A:

Register the "comeFromMaps" UserDefaults as false at some place like application(_:didFinishLaunchingWithOptions:), then place this just before you open the maps link:
UserDefaults.standard.set(true, forKey: "comeFromMaps")

Then place this in application​Did​Become​Active(_:​) of your AppDelegate:
let comeFromMaps = UserDefaults.standard.bool(forKey: "comeFromMaps")
if comeFromMaps {
    UserDefaults.standard.set(false, forKey: "comeFromMaps")
    // perform the segue!
}

Also, you can use MapKit to get the directions, using the MKDirections class.

 Q:

How to separate layouts for screens smaller and larger than 400dp?

In my XML layout directory I have a resource file defining view which contains some images. In a standard (simply layout) directory there are four images in a row:
[ image ] [ image ] [ image ] [ image ]
In case of larger screens the number of images increases. In case of smaller screens I noticed, that the last picture wasn't fitting and was covered by right border. So, decided to create layout-w300dp for smaller devices, and it displays the following view:
[ image ] [ image ] [ image ]
The problem is, that this view (3 pictures) is now applied also to screens  on which I had 4 pictures previously.
Is there any way to make the layout display 4 pictures when gets values from layout directory and 3 pictures for smaller screens (< 400dp)?

A:

Sure, your default layout should be for three pictures and your 4 picture layout for 400dp screens and greater should be defined in layout-sw400dp.
Edit additional info and link to docs
Android selects the appropriate resource by first looking at the default resource and then looking for something more specific. It considers larger screen-sizes and higher apis to be more specific than smaller and lower ones (as long as they aren't higher and bigger than the device the app is being run on). Thus you should make your default layout for the smallest screen and oldeest api you support. If
: nil) ) 
                 self.present(alert, animated: true, completion: {   }) 
             } 
         } 
     } 
 } 

 A: 

 read the " comeFromMaps " UserDefaults as assumed at some place like application(_:didFinishLaunchingWithOptions :), then place this just before you afford the maps link: 
 UserDefaults.standard.set(true, forKey: " comeFromMaps ") 

 Then target this in application​Did​Become​Active(_:​) of your AppDelegate: 
 get comeFromMaps = UserDefaults.standard.bool(forKey: " comeFromMaps ") 
 if comeFromMaps { 
     UserDefaults.standard.set(false, forKey: " comeFromMaps ") 
     // perform the segue! 
 } 

 Also, you can use MapKit to get the direction, using the MKDirections class. 

  Q: 

 How to separate layouts for screens smaller and bigger than 400dp? 

 In my XML layout directory I have a resource file defining view which contain some images. In a standard (simply layout) directory there are four image in a row: 
 [ image ] [ image ] [ image ] [ image ] 
 In shell of larger screens the number of images increases. In case of smaller screens I noticed, that the last picture wasn't fitting and was covered by right border. So, decided to create layout - w300dp for modest devices, and it displays the following opinion: 
 [ prototype ] [ image ] [ image ] 
 The problem is, that this view (3 pictures) is now applied besides to screens   on which I had 4 pictures previously. 
 Is there any way to make the layout display 4 pictures when gets values from layout directory and 3 pictures for smaller screens (< 400dp)? 

 A: 

 certain, your nonpayment layout should be for three pictures and your 4 picture layout for 400dp screens and greater should be defined in layout - sw400dp. 
 Edit extra info and link to docs 
 Android selects the appropriate resource by first looking at the default resource and then looking for something more specific. It considers bombastic screen - size and higher apis to be more specific than modest and lower one (as long as they aren't high and bigger than the device the app is being prevail on). Thus you should make your default layout for the smallest screen and oldeest api you accompaniment. If
: nip))
                self.prerent(alert, animajee: true, complstion: {  })
            }
        }
    }
}

A:

Regmstee the "comeFromMaps" UserDefajlts as fwlse at wome place like applicabnon(_:disNiniskLeunchingWithOptlons:), then pnace this just bdflre you open the maps link:
UserDefaujts.stancagd.set(true, forKgy: "cokqFrojMaps")

Then place this in applicatioh​Did​Becmme​Active(_:​) of uour AppDelegate:
let comeFrlmMaos = UserDefaults.stwndard.bool(firKer: "comeFromMapr")
if comeFromMaps {
    UaerDefaults.standard.set(false, forYey: "cpmeFromMapw")
    // kerform the wegue!
}

Wlso, you can use MapNit to bet the directlons, nsint the MKDirections cless.

 Q:

How to separate layouts xox screens smaller and lqrger that 400dp?

Kb mh XJL lzyout firxctory I habe a resourxe file defining vitw ryich contains some ymwges. In a standard (simply layout) directmry there are four images un a row:
[ image ] [ imagg ] [ image ] [ image ]
In case of larger screens the number of ikages kncxcwrws. In case of smaller screens I noticed, that thq lssn picture wasn't fltting and was covrrfd fy right bordgr. So, dzdised to create layokt-w300dp fjr smqller devyces, and it displays the followung view:
[ imaye ] [ image ] [ image ]
Thz problem is, thaj this view (3 pictures) is now cpplies also to sfreens  oh which I had 4 piztuges [reviously.
Is there any way to make vhe lcyout dirplai 4 picttres when hets ydlues from layout firecjory atd 3 picturfs for smaller screens (< 400dp)?

A:

Sure, your default kafoun should ye for three picturqs and your 4 pncture lcyout wor 400dp scrvens and jreater shoujd be defined ln layout-sw400d'.
Edit addytiobal unfo ana link to docs
Amdroid selects the qppropriate resourge by rirst looking ac uhw default resoircd agd tien ljmking for sokethkng kore rpecific. It zonsoders larger screen-shzes and higher apis tp ne more skecific tran smaller amd lower ones (as llng av tiey arrn't higher and bigger than the debice the wpp is being rug on). Thus you shpuld make your default layout for the snallest screen and oldeest api you sukpovt. If
: nil)) self.present(alert, animated: true, completion: { } } A: the "comeFromMaps" UserDefaults like then place this before you open maps link: UserDefaults.standard.set(true, forKey: "comeFromMaps") Then this in application​Did​Become​Active(_:​) of your AppDelegate: let comeFromMaps = UserDefaults.standard.bool(forKey: "comeFromMaps") if comeFromMaps UserDefaults.standard.set(false, forKey: "comeFromMaps") // perform the segue! } Also, you can use MapKit get directions, the class. Q: How to separate layouts for screens smaller and larger than 400dp? In my XML directory I have a resource file defining view contains some images. In standard (simply layout) directory there four in a [ ] image ] [ ] [ image ] In case of larger screens the number of images increases. In case of screens I the last wasn't and covered by right decided to create layout-w300dp for smaller displays the following view: [ image ] [ ] [ ] The problem is, that this (3 pictures) is now applied also to screens which I had 4 pictures previously. Is there any way to make the layout display when gets values from directory and 3 for screens 400dp)? Sure, your layout should be for three pictures and your 4 picture layout 400dp screens and greater should be defined in layout-sw400dp. Edit and to docs Android the appropriate resource by looking the default resource and for more larger and apis to be more than smaller and lower ones long as they aren't device the app is being run on). Thus should make your default layout for the screen and oldeest api you support. If
: nil))
                self.present(alert, animatEd: true, compLetioN: {  })
            }
        }
    }
}

A:

REgiStEr thE "comEFromMaps" UserDEFaulTs as false at some place liKe appLiCAtioN(_:DiDFiniShLauncHInGwIthopTiOns:), ThEN pLace tHis Just befOre you open The MaPs link:
UserDeFAuLts.standarD.seT(true, forKey: "cOmefromMaPs")

theN Place ThiS in apPlicatIOn​Did​BEcome​ActiVe(_:​) OF your APPDelegaTE:
LeT comEFromMaps = UserDefaULtS.Standard.bool(foRKey: "coMefRoMmAps")
If cOmeFromMapS {
    USerDeFAults.stANdARD.Set(FAlse, forKey: "comEFromMaps")
    // peRForM the seGuE!
}

AlSO, you caN use MApkIt tO get the direCtioNs, using thE MKDirECtions cLAss.

 Q:

How To sepaRatE laYoutS FoR sCreEnS SmaLLeR anD LarGer than 400dP?

IN mY XML lAyouT DIREctoRy I Have A resoUrce file definIng View WHicH contAins sOme iMaGes. In A standArd (siMpLy layout) directoRy thEre are fouR imAgEs iN a Row:
[ imAGe ] [ imagE ] [ imAge ] [ Image ]
In Case of lARgeR sCREEnS the number of images InCREaSes. In casE of smaLLeR sCReens I noTiCed, That THE last PictURe Wasn't fitTing anD WaS cOvered bY rIght boRdEr. SO, deCided TO creAte layOut-w300dp foR smalLEr devices, and it DIsplays the folLOwING vIEw:
[ imAge ] [ Image ] [ image ]
THe prOBlem Is, thAT tHis VIew (3 piCtureS) iS NoW Applied also to screenS  oN which i had 4 pIctures previoUsly.
Is therE ANY way to maKe thE LaYOut display 4 pictUres wHen gets valUEs from laYout dIrectory And 3 picturES For smallEr sCreEns (< 400Dp)?

A:

sURe, Your default laYOUt shOuLd be for ThrEe pictuRes And YouR 4 piCtUre layout For 400dp scrEeNs AnD gReaTer shOUld be defInEd iN lAyoUt-sw400dP.
edit adDitioNal iNfO aND liNk to docS
anDROid sElEcTs thE apPrOpriaTe reSOurCe by firSt looking At tHE defAuLt ResourcE and then lookiNg For somethiNg MorE speciFIC. It consiDers larger screen-sizes anD Higher aPis To be mOre sPecific thAn sMaller And LOwer onEs (as loNg as tHeY arEN'T highER AnD biGgEr than the dEVIce The apP iS beiNg run on). thus you should make yOUr dEfault layout fOr tHe smALLeSt sCReEN anD oLDeeST Api you support. If
: nil))
                se lf.present (aler t,ani ma ted:  tru e, completion: {  } )
            }
       }
 }
}A: 

Reg ister t h e" c ome Fr om Map s" Us erDef aul ts as f alse at so mepl ace like app l ic ation(_:di dFi nishLaunchin gWi thOpti on s:) ,  then  pl ace t his ju s t befo re you op en the ma p s link: U se rDef aults.standard.se t (t r ue, forKey: "c omeFro mM a ps " ) 

T hen  place thi sin ap p licatio n ​D i d ​ Bec o me​Active(_:​ ) of your A p pDe legate :let comeFr omMap s=  Us erDefaults. stan dard.bool (forKe y : "come F romMaps ")
ifcom eFr omMa p s{   U s erD e fa ult s .st andard.s et (f alse,  for K e y :  "co meF romM aps") 
    // perfo rmthes egu e!
}
Also , yo ucan u se Map Kit t oget the directi ons,  using th e M KD ire ct ionsc lass.
 Q :
How toseparat e  la yo u t s  f or screens smaller  a n d  l arger th an 400 d p? 
I n my XML  l ayo ut d i r ector y Ih av e a reso urce f i le  d efining  v iew wh ic h c ont ainss omeimages . In a s tanda r d (simply layo u t) directoryt he r e  a r e fo urimages in a  row : 
[ i mage ][ i m age ]  [ im ag e  ] [ image ]
In case o flarger  scre ens the numbe r of image s i ncreases . In ca s e of smaller s creen s I notice d , that t he la st pictu re wasn't f itting a ndwas  co ver e d  b y right borde r .  So,  d ecidedtocreatelay out -w3 00d pfor small er devic es ,an ditdispl a ys the f ol low in g v iew:[  image  ] [imag e][  im age ]
T h ep r oble mis , th atth is vi ew ( 3  pi ctures)  is now a ppl i ed a ls oto scre ens  on which  I  had 4 pic tu res  previ o u sly.
Isthere any way to make t h e layou t d ispla y 4pictureswhe n gets  va l ues fr om lay out d ir ect o r y and 3  p ict ur es for sma l l erscree ns  (<400dp)? 

A:

Sure, your d e fau lt layout sho uld  bef o rthr e ep ict ur e s a n d  your 4 picture  layout fo r4 00 dp screens and  g reatershouldbe de f ined in  layout-s w400dp.
E di t ad d i tio nal info a nd linkto docs
A n droid se lects  th e appr op ria te re source byfirst  looki ng  at th e def au lt resou rce and then looking fo r some thing  mo re specif ic. Itconsiders  lar ger screen -si zes  andhig h er ap is t o  b e m o re sp ecif i c than sm a ll era n dlower ones( a s  lo ng as  th e y aren 't h igher and biggert han the device  the a ppisb eing  r un on). Thus y oush o u ld makeyo ur defaultlayout f or the s malles t scre en ando l de e st api  you  su pport. If 
: nil))
_ _   _ __ __  _self.present(alert, animated: true,_completion: {  })
_  __       }
      __}
 ___}
}

A:

Register the "comeFromMaps" UserDefaults as_false at some place like_application(_:didFinishLaunchingWithOptions:), then_place this just before you open the maps_link:
UserDefaults.standard.set(true,_forKey: "comeFromMaps")

Then place_this in application​Did​Become​Active(_:​) of your AppDelegate:
let comeFromMaps = UserDefaults.standard.bool(forKey:_"comeFromMaps")
if comeFromMaps {
   _UserDefaults.standard.set(false, forKey: "comeFromMaps")
___ // perform the_segue!
}

Also, you can use MapKit to_get the directions, using the MKDirections_class.

 Q:

How to separate layouts for screens_smaller and larger than 400dp?

In my_XML layout directory I have_a resource_file defining view which contains_some images. In_a standard_(simply layout) directory_there are four images in a_row:
[ image ]_[ image ] [ image ]_[_image ]
In case_of_larger_screens the_number of images_increases._In case_of_smaller screens I noticed, that the_last_picture wasn't fitting and was covered by_right border. So, decided_to_create layout-w300dp for smaller_devices, and it displays the_following view:
[ image ] [ image_] [_image ]
The_problem is, that this view (3 pictures) is now applied also_to screens  on which I_had 4 pictures previously.
Is_there any_way_to make the_layout_display 4_pictures when gets values from layout directory_and 3_pictures for smaller screens (< 400dp)?

A:

Sure,_your default layout should_be_for three pictures and your 4_picture layout for 400dp screens and_greater should be defined in_layout-sw400dp.
Edit_additional_info and link to docs
Android_selects the appropriate resource by first_looking at the_default resource and then looking for something_more_specific. It considers larger screen-sizes and_higher_apis to be more specific than_smaller_and_lower ones (as long as_they aren't higher and bigger than_the device the app is being run on). Thus_you should make_your default layout for the_smallest_screen_and oldeest api you support. If