Black Magic
Black Magic

Reputation: 2766

IOS - UIImageView to other subview?

I have a UIImageView that I add as a Subview to another subView:

[self.mapView addSubView:imgview];

But when I push the back button it takes me back to the mainview. Is there any way I can make sure it takes me back to the mapview? Override the backbutton for instance? Thanks

Upvotes: 0

Views: 54

Answers (2)

Jay Gajjar
Jay Gajjar

Reputation: 2741

You need the remove the UIImagView which you just added. If you are adding multiple UIImageView in your mapview then you need to add unique tag to each UIImageView you add. Then you can remove the UIImageView using that tag.

Upvotes: 0

Mutawe
Mutawe

Reputation: 6524

Try this:

-(void)back{

if (imgview.superView) {
    [imgview removeFromSuperview];
    return;
}


[self.navigationController popViewControllerAnimated:YES];
}

Upvotes: 1

Related Questions