5

I have write a function thats displays the toast on UIVIewController. The toast function is given below

-(void)showToast:(NSString*)string
{
    MBProgressHUD *hud;
    hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = string;
    hud.margin = 10.f;
    hud.yOffset = 150.f;
    hud.removeFromSuperViewOnHide = YES;
    hud.userInteractionEnabled = NO;
    [hud hide:YES afterDelay:2];
}

Now the issue is that my toast message hides behind the keyboard. Can anyone tell me how to show toast above the height of keyboard?

Usman Javed
  • 2,437
  • 1
  • 17
  • 26
  • please check this link http://stackoverflow.com/questions/17161590/how-to-add-a-uiview-over-the-keyboard-ios – Rahul Nov 27 '15 at 13:00

1 Answers1

1

Similar question with answer is here: Position MBProgressHUD at the Bottom/Top of the screen

In short, use the yOffset property of the MBProgressHUD to change its Y position.

Community
  • 1
  • 1
Vrasidas
  • 2,085
  • 1
  • 17
  • 23