简体   繁体   中英

Anchor button to bottom of screen above tabbar ios

we have a couple screens where there is one button with one action to take, but the rest of the screen scrolls (full of info). So I want anchor the button to the bottom of the screen. This app has a tabbar, so the button is actually anchored 49pts above the base of the screen. This works just fine until someone goes to type into a text box. At this point the button that appears anchored at the bottom of the screen is just hanging out 49pts above the keyboard.

How do I fix this?

Here are a couple screen shots of what I'm talking about. 正确操作按钮

文字错误

Figured it out. Here is the code I was using incase anyone has a similar problem. Since the keyboard takes up half the screen I only moved the button and label half the distance of the toolbar.

- (void) keyboardDidShow: (NSNotification *)notif {
    _lblContinueBG.center = CGPointMake(_lblContinueBG.center.x, _lblContinueBG.center.y + 25);
    _btnContinue.center = CGPointMake(_btnContinue.center.x, _btnContinue.center.y + 25);
}
- (void) keyboardDidHide: (NSNotification *)notif {
    _lblContinueBG.center = CGPointMake(_lblContinueBG.center.x, _lblContinueBG.center.y - 25);
    _btnContinue.center = CGPointMake(_btnContinue.center.x, _btnContinue.center.y - 25);
}

This page helped out a bunch too - similar post. Creating object programmatically and changing that object's position

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM