Try this:
[self.view.superview.superview removeFromSuperview];
Another approach, much cleaner, would be using notifications: you could send a notification to the object controlling your main view, so that it removes it right bar subview. It would be something like:
In your main view controller:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(removeRightBar:)
name:@"RemoveRightBarNotification"
object:nil];
- (void) receiveTestNotification:(NSNotification *) notification
{
<REMOVE SUBVIEW FROM mainView>
}
and in your table view controller:
[[NSNotificationCenter defaultCenter]
postNotificationName:@"RemoveRightBarNotification"
object:self];
In this case notification will provide a very loose connection between the main view and the table view controller.