Generally, states have overall laws, but cities can have specific laws. Unless a state makes a law that states that all guns are legal, and that no city, county, or municipality shall infringe upon. Then cities generally can make laws prohobiting certain types or all firearms.
The Peoples Republic of Chicago bans handguns, but they're legal in most of the rest of the Socialist State of Illinois. Now the state recently passed a law stating that if somebody shoots somebody in self defense of their lives or property, and the city of residence has a law banning guns, the person cannot be prosecuted by the city, even though the person technically broke the law.
This was in response to a situation that happened about a year ago or so, where someone broke into a home in Highland Park. The same person broke in again the next night, this time the entire family was home. Dad had a gun in the house, illegal in Highland Park, and shot the burglar. The city was originally going to prosecute, until the uproar. The city saw negative publicity they were receiving, and reversed their stand. After that state law makers fast tracked a law protecting residents from this situation.
Its still illegal to own a hand gun in Highland Park or Chicago, but a resident can't be prosecuted for breaking that law in defense of their home.
If state law simply allowed gun ownership, over ruled city laws that banned gun ownership, then federal law, or the second amendment would over rule all.
Thanks for the info on Illinois gun laws. Glad I don't live there.