I wonder how does an inductor resist the changing magnetic field, all the information I searched said that there is no current in the moment when the inductor is connected to the battery. This is really confusing me, no current means no magnetic field, however, to generate a magnetic field that resists changes in magnetic flux, there must be a magnetic field inside the inductor at the beginning. Therefore, I think that the maximum current should flow through the inductor at the moment of switching on, then a magnetic field that resists the change is generated to offset this current. But it doesn’t seem to be the case.
Think about it this way: A magenetic field stores energy. Therefore to create a magnetic field you must deliver energy to the system somehow. In the case of an inductor, the only input to the system that can deliver this energy is the electrical power provided to the inductor ($I\times V$).
And if the power provided is not infinite, then the stored energy can only change at a finite rate. Therefore the magnetic field can only change at a finite rate. Therefore the current can only change at a finite rate.
to generate a magnetic field that resists changes in magnetic flux,
It's not the magnetic field that resists changes in flux. It's the simple fact that the magnetic field stores energy that ensures that the magnetic field can't change instantaneously without providing infinite power to the device.
Therefore, I think that the maximum current should flow through the inductor at the moment of switching on,
A large current through the inductor implies a large magnetic field in the core. You must consider, where did the energy come from to generate this magnetic field?
The magnetic field can only build up slowly, because you can only provide the energy to form the field at a finite rate (i.e. finite power)