Aayush Katiyar Aayush Katiyar - 6 months ago 31
iOS Question

How to reset all three button text on click of cancel button?

I am using three filters and filter text will display on label on selecting the cell, i want to do that when there is no result of search then click on cancel button will reset all the text like the image showing below

enter image description here

enter image description here

enter image description here

on click of cancel button blank screen comes

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SearchResultVC *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"SearchResultVC"];

[self.navigationController pushViewController:vc animated:YES];

}


but when i am using

[self dismissViewControllerAnimated:YES completion:Nil];


it is showing like this enter image description here

Answer

Simply use this code it will open your default home page by clicking back/Cancel button

    -(void)back
    {
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    yourViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"YourViewControllerID"];
    [self presentViewController:vc animated:NO completion:nil];

    }