1

I have a weird case where I'm using the awesome SWRevealViewController from John Lluch to have 2 side navigation controllers (like the Facebook app) that slide out to the left and the right when a UIBarButtonItem is touched.

However - I need the front view controller to make sure to resign first responder whenever these actions happen, but the associated actions for those bar buttons happen in another View Controller class.

I need to either:

  1. Associate another action with the UIBarButtonItem that I can call in the view that needs to resign first responder OR
  2. Resign first responder for the main view either on ViewDidAppear for either of the side views, or in the SWRevealController class

Can you resign first responder for one view from another view controller?

1 Answer 1

2
you can do it using NSNotificationCenter as below.

//.m file:  
 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(LoadTableBasedOnCorner:) name:@"LoadTable" object:nil]; 

in which class you use above addObserver, you have to implement that method.

//.m file from where you want to send action, call method as below.

[[NSNotificationCenter defaultCenter] postNotificationName:@"LoadTable" object:nil];
1
  • 1
    That's actually what I did! I was hoping for a better answer, but that did work marvelously. I don't know enough about Objective-C (or honestly the memory management in any language), but it felt like a memory intensive solution to me, since it becomes readable in every single class. Still, it hasn't slowed anything down and we use almost 0 memory in this app, so it's whatever. Jul 29, 2013 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.