I create custom login page by using UIAlerView subclass. Now when i click on button it opens up UIAlertView I want to change the main view based on which button is pressed.
But as all implementation of UIAlerView is in another class though i change the view it doesn't retain that as that class variable doesn't get it's value.
Can anyone please help me with this? I can post the code if required.
Thank you, Ankita
You can use a custom init method like below for alertView and store the _sender in global or class variable. like
id sender; - (id)initWithSender:(id)_sender { self = [super init]; if (self) { sender=_sender; } return self; }
from RootVC/bgview initialize alertView as follows and define a method named
-(void) alertIndexSelected:(NSInterger) index;in rootvc/your main view.{
//change the backgound view based on button selected }
alertViewobj =[[alertView alloc] initWithSender:self];
when the button is selected on alertview call the below method, this will notify your rootvc about which index of alert is pressed. use following alertview delegate.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { [sender alertIndexSelected: buttonIndex]; }