由于虚拟键盘的会占据原因,如果我的一个textField在屏幕下方就看不到了。我的想法是,在
- (void)textFieldDidBeginEditing:(UITextField *)textField  里面创建一个view,里面再在上面创建一个新的textView,让用户在textField输入,输入完后我在吧结果送到textField 。但是当我创建一个view并addSubView后,发现下面的那个View还是活动的,就是用户可能点击到下面的空间,应该怎么屏蔽呢?最好可以让新的view是半透明的,就是可以看到后面的view的内容但是不能操作。
效果如图,label是后面的view的空间,不希望用户可以操作,上面ceshi是
textView

解决方案 »

  1.   

    网上有很多解决方法的。用notification。可以用scrollview 也可以用view的annimation
      

  2.   

    不用这么麻烦的。只要注册两个通知,当键盘出现的时候向上移动view(保证UITextField不被遮挡),键盘消失的时候向下移动view至原位置。-(void)viewWillAppear:(BOOL)animated 
    {
        [super viewWillAppear:YES];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];    
    }-(void)viewWillDisappear:(BOOL)animated 
    {
    [super viewWillDisappear:YES];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
    }- (void)keyboardWillShow:(NSNotification *)aNotification 
    {
        NSTimeInterval animationDuration =
    [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
        [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
        [UIView setAnimationDuration:animationDuration];
        self.view.center = CGPointMake(160, 180);
        [UIView commitAnimations];
    }- (void)keyboardWillHide:(NSNotification *)aNotification
    {
        NSTimeInterval animationDuration =
    [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
        [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
        [UIView setAnimationDuration:animationDuration];
        self.view.center = CGPointMake(160, 240);
        [UIView commitAnimations];
    }
      

  3.   

    我没有积分发帖,搭车求下ocf、epub、mobi格式电子书的制作方法和软件介绍