While studying UIApplication, I find a way to add a view on top of all UIViewController.
UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(40,40,250,250)];
[testView setBackgroundColor:[UIColor redColor]];
[[[UIApplication sharedApplication] keyWindow] addSubview:testView];
It is displaying correctly.
I am wondering if I created a menu with some buttons instead of testView. Where can i handle those events in AppDelegate or Current ViewController
If it is possible
then tell me how to change text of any ViewController
on clicking menu button.
I mean how to get the context of another ViewController and set its View Property from that button.
Yes, it is possible. You can add button and set it's action events. Then you may add Observer using
NSNotificationCenter
. Then you can receive notification about the button click in whicheverUIViewController
you want.Here is the code:
add button like this:
Post notification in button event handler:
Receive the notification in another ViewController:
Then in 'yourmethod', you can change the text.