Ants sometimes do this without an iPhone too. Apart from the magnetic field being disrupted they basically rely on a follow the leader method of navigation to get around. If the leader ant gets lost and starts circling so will the rest until they eventually die of exhaustion
http://www.sciencealert.com/watch-strange-footage-shows-ants-circling-an-iphone-when-it-rings