相关疑难解决方法(0)

如何在iOS 7上模仿键盘动画,将"完成"按钮添加到数字键盘?

我一直在做这样的事情来模仿旧版iOS上的键盘动画.

CGRect keyboardBeginFrame;
[[note.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&keyboardBeginFrame];
self.doneKeyboardButton.frame = CGRectMake(0, (keyboardBeginFrame.origin.y + keyboardBeginFrame.size.height) - 53, 106, 53);
[[[[UIApplication sharedApplication] windows] lastObject] addSubview:self.doneKeyboardButton];

CGPoint newCenter = CGPointMake(self.doneKeyboardButton.superview.frame.origin.x + self.doneKeyboardButton.frame.size.width/2,
                                self.doneKeyboardButton.superview.frame.size.height - self.doneKeyboardButton.frame.size.height/2);

[UIView animateWithDuration:[[note.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]-.02
                      delay:.0
                    options:[[note.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]
                 animations:^{
                     self.contentView.frame = CGRectOffset(self.contentView.frame, 0, -TextFieldViewMovement);
                     self.doneKeyboardButton.center = newCenter;
                 }
                 completion:nil];
Run Code Online (Sandbox Code Playgroud)

但是,这已停止在iOS7上运行.看起来返回的值不再完全正确,完成按钮不再完全模仿键盘显示动画.

keyboard animation objective-c uiview ios

27
推荐指数
4
解决办法
1万
查看次数

LLVM是否将Objective-C方法转换为内联函数?

  1. LLVM是否会在可能的情况下自动将Objective-C方法转换为内联函数?

    (即,为一块代码创建一个Objective-C方法,你可以在其他方式粘贴内联吗?)

  2. 如果LLVM不执行此优化,为什么不呢?如果是,(a)是否有必须为此设置的某些构建设置?(b)如何判断是否内联Objective-C方法?

performance objective-c llvm inline-functions

13
推荐指数
3
解决办法
2156
查看次数

在eventFirstResponder或resignFirstResponder的情况下,将对象保持在键盘顶部?

我目前在键盘上有一个UITextField.点击它时,它应该粘在键盘顶部并平稳向上移动.我不知道键盘的确切持续时间和动画类型,所以它真的很颠簸.这就是我所拥有的:

[theTextView resignFirstResponder];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.25];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
// Frame changes go here (move down 216px)
[UIView commitAnimations];

[theTextView becomeFirstResponder];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.25];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
// Frame changes go here (move up 216px)
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

如果有人之前做过这样的事情,我想知道你用来使动画变得平滑的设置,并让它看起来像是"卡在"键盘的顶部.

iphone objective-c uitextfield becomefirstresponder resignfirstresponder

13
推荐指数
2
解决办法
7672
查看次数

键盘处理就像iOS 7中的Messages app一样

我正在实现一个类似于Messages应用程序中发生的视图,因此有一个视图,UITextView附加到屏幕的底部,还有UITableView显示主要内容.当它被轻敲时,它会随着键盘向上滑动,当键盘被解除时,它会滑回到屏幕的底部.

我有这个部分并且它完美地工作 - 我只是订阅键盘通知 - 将隐藏和显示.

问题是我已经在UITableView上将键盘解除模式设置为交互式,并且我无法在平移时捕获对键盘的更改.

第二个问题是这个uitextview栏覆盖了uitableview的某些部分.如何解决这个问题?我仍然希望uitableview像在消息应用程序中一样"在"这个栏下面.

我在所有地方都使用AutoLayout.

任何帮助将不胜感激!

============

EDIT1:这是一些代码:

查看层次结构如下:

视图 - UITableView(这个将包含"消息") - UIView(这个将滑动)

UITableView对父视图的顶部,左侧,右侧和底部有约束,因此它填满整个屏幕.UIView对父视图的左侧,右侧和底部有约束,因此它粘在底部 - 我通过调整约束的常量来移动它.

在ViewWillAppear方法中:

NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.DidShowNotification, OnKeyboardDidShowNotification);
NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillChangeFrameNotification, OnKeyboardDidShowNotification);
NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, OnKeyboardWillHideNotification);
Run Code Online (Sandbox Code Playgroud)

以下是方法:

void OnKeyboardDidShowNotification (NSNotification notification)
{
    AdjustViewToKeyboard (Ui.KeyboardHeightFromNotification (notification), notification);
}

void OnKeyboardWillHideNotification (NSNotification notification)
{   
    AdjustViewToKeyboard (0.0f, notification);
}

void AdjustViewToKeyboard (float offset, NSNotification notification = null)
{
    commentEditViewBottomConstraint.Constant = -offset;

    if (notification != null) {
        UIView.BeginAnimations (null, IntPtr.Zero);
        UIView.SetAnimationDuration (Ui.KeyboardAnimationDurationFromNotification (notification));
        UIView.SetAnimationCurve ((UIViewAnimationCurve)Ui.KeyboardAnimationCurveFromNotification (notification));
        UIView.SetAnimationBeginsFromCurrentState (true);
    } …
Run Code Online (Sandbox Code Playgroud)

uitableview uikeyboard ios autolayout xamarin

10
推荐指数
3
解决办法
7084
查看次数

用键盘动画UIView

我需要在即将开始的项目中添加聊天功能.

与此同时,我一直在努力实现我所期望的简单问题,即在屏幕底部有一个UIView,里面有一个UITextView,当用户点击UITextView时,它会用键盘设置动画.

我有它工作,但不幸的是键盘的动画略微落后于它上面的视图.这是我到目前为止的实现:

注册键盘通知:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

键盘通知方法:

- (void)keyboardWillShow:(NSNotification*)notification
{
    CGFloat duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue];
    NSInteger curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];

    [UIView animateWithDuration:duration delay:0 options:curve animations:^{

        CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
        _chatViewBottomConstraint.constant = keyboardFrame.size.height;
        [self.view layoutIfNeeded];

    } completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

有没有其他人做过类似的事情,能否为我提供更好的解决方案?

objective-c uikeyboard ios

5
推荐指数
2
解决办法
6217
查看次数