During cold start, the air is bypassed around the throttle via the iacv and the engine uses a slightly different fuel map....so if you are idling okay at startup then i think the iacv might be okay. However, you will want to check that the iacv closes after warmup. When you first start the truck, the air going into the engine will sound like a hissss.....but when the operating temp gets into range, the iacv should close and the hiss should go away.
I would also check for air leaks past the MAF sensor (which usually causes poor idling). If you have an aftermarket air filter, check the intake tube to make sure all hoses (including the small one on the bottom of the FIPK for example) are connected.
As for the Knock sensor, if it is intermittent, sounds like you make have a loose connection on the connector pins for the knock sensor (connector plug on the valve cover). The KS will not set a code unless the voltage is out of range. The voltage will not be "out of range" with a good knock sensor, even when it is sensing knock. If you get code p0328, it means the knock sensor voltage is reading high....which may indicate a loose connection on the connector pin. If you get a code p0327, that indicate a low voltage reading....which means the knock sensor is either bad or shorted to the block.