首先在程序中引用

#include <sys/reboot.h>

然后使用

reboot(RB_HALT);

就可以直接将iPhone关机。