when you he is going to side b, sometimes run off missiles is enough to knock them away. With Up B, you have to respect it unless you can grab ledge at the right time. From there you have a few steps to consider to complete the edgeguard.
One, time your ledge grab well. If he tried sweetspotting and you grab ledge at the right time, he will fail and lose that stock. If, however, Ike throws his up b high, then tough luck, the edgeguard continues.
Two, If you are fast enough, as the sword is spinning above you, and ike is right under you, you can drop into a dair, or nair. Bair is not mentioned because if you had the time to set up a bair, you could have just as easily used dair and been done with it. The dair is stricter with timing but is almost always an edgeguard kill confirm. Nair is safer, but depending on if you got the stronger hit or not, Ike might have the ability to up b again.
Three, if you didn't have the time to intercept Ike and he is now above and about to come down, he can do two things. He can land onstage, or try to smack you off the ledge. If he lands on stage, you can punish him there, but you will have to be quick since his recovery on his up b land onstage is pretty quick. If, however, he tries to go for ledge, a ledge roll is enough that he will just lose that stock.
The hardest part here is just grabbing ledge at the right time. It is really hard to react to so that is not a feasible piece of advice. Rather, it is safer to just grab it when you can feel it coming. If you grab too early, at least you can roll back onstage and have stage control. If you get hit by the up b, Ike might be in the right position to retaliate and get you offstage.
I hope this helps.