Nanowire Ultraviolet Photodetectors and Optical Switches