Which metal ions precipitate in NH4OH?
For the case of magnesium ion, at least, it seems a stretch to say it dissolves in ammonia solution.  Assume that the ammonia solution has $\mathrm{pH}$ of $11$ and magnesium hydroxide has a solubility product of $5.61×10^{-12}$. We infer that the magnesium ion solubility at equilibrium with the hydroxide in ammonia solution is only $\pu{5.6μM}$ which is not really all that soluble.  

Magnesium ion is appreciably soluble not in an ammonia solution but in a buffered solution of ammonia and an ammonium salt.