Both will detect objects in the way.
IR is cheap, and good for most applications, ultrasound is expensive, and can usually detect longer distances, IR is perfect for starting, I never felt the need for ultrasound.
And oh, good IR sensors don't get affected by sunlight.