亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

彈出鍵盤textview

發布時間:2020-08-01 12:43:37 來源:網絡 閱讀:412 作者:Q一抹陽光Q 欄目:開發技術

- (void)setTextView {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 528, 320, 40)];
    view.backgroundColor = [UIColor lightGrayColor];
    view.tag = 100;
    [self.view addSubview:view];
    [view release];
    
    UIImageView *p_w_picpathView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 30, 30)];
    p_w_picpathView1.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;//設置p_w_picpathView1的自適應高度,和父視圖保持的下邊距保持不變
    //p_w_picpathView1.p_w_picpath = [UIImage p_w_picpathNamed:@"bottleReceiverVoiceNodePlaying003@2x.png"];
    p_w_picpathView1.layer.cornerRadius = 15;
    p_w_picpathView1.clipsToBounds = YES;
    [view addSubview:p_w_picpathView1];
    [p_w_picpathView1 release];
    
    UIImageView *p_w_picpathView2 = [[UIImageView alloc] initWithFrame:CGRectMake(230, 0, 30, 30)];
    p_w_picpathView2.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    //p_w_picpathView2.p_w_picpath = [UIImage p_w_picpathNamed:@"Album_ToolViewEmotionHL@2x.png"];
    p_w_picpathView2.layer.cornerRadius = 15;
    p_w_picpathView2.clipsToBounds = YES;
    [view addSubview:p_w_picpathView2];
    [p_w_picpathView2 release];

    UIImageView *p_w_picpathView3 = [[UIImageView alloc] initWithFrame:CGRectMake(280, 0, 30, 30)];
    p_w_picpathView3.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    //p_w_picpathView3.p_w_picpath = [UIImage p_w_picpathNamed:@"AlbumAddBtnHL@2x.png"];
    p_w_picpathView3.layer.cornerRadius = 15;
    p_w_picpathView3.clipsToBounds = YES;
    [view addSubview:p_w_picpathView3];
    [p_w_picpathView3 release];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60, 37, 200, 2)];
    label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    label.backgroundColor = [UIColor purpleColor];
    [view addSubview:label];
    [label release];
    
    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(60, 0, 160, 36)];
    //autoresizing 自適應高度,是UIView的屬性,可實現自動布局,
    //   self.textView.autoresizingMask = UIViewAutoresizingNone; //不會隨父視圖的改變而改變
    //   self.textView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; //自動調整view與父視圖左邊距,以保證右邊距不變
    //    self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth;//自動調整view自身的寬度,保證左邊距和右邊距不變
    //    self.textView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;//自動調整view與父視圖右邊距,以保證左邊距不變
    //    self.textView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;//自動調整view與父視圖上邊距,以保證下邊距不變
    //   self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自動調整view自身的高度,以保證上邊距和下邊距不變
    //    self.textView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;//自動調整view與父視圖的下邊距,以保證上邊距不變
    textView.tag = 200;
    textView.scrollEnabled = YES;
    textView.editable = YES;
    textView.textAlignment = NSTextAlignmentLeft;
    textView.dataDetectorTypes = UIDataDetectorTypeAll;
    textView.delegate = self;
    textView.returnKeyType = UIReturnKeyDefault;
    textView.keyboardType = UIKeyboardTypeAlphabet;
    [view addSubview:textView];
    [textView release];
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    return YES;
    
}
- (void)keyboardWillShow:(NSNotification *)notification {
    NSDictionary *userInfo = [notification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    CGFloat keyboardHeight = keyboardRect.size.height;
    
   
    /*
    UIView *view = [self.view viewWithTag:100];
    
    CGRect rect = view.frame;// 保存View原有的frame.
    rect.origin.y -= keyboardHeight;//y減去鍵盤的高度
    view.frame = rect;//把最新的frame賦值給view
    [UIView commitAnimations];
    */
    
   self.view.frame = CGRectMake(0, -keyboardHeight, 320, 568);
    
    
}

- (void)keyboardWillHide:(NSNotification *)notification {
    self.view.frame = CGRectMake(0, 0, 320, 568);

    /*
    NSDictionary *userInfo = [notification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    CGFloat keyboardHeight = keyboardRect.size.height;

    UIView *view = [self.view viewWithTag:100];
    
    CGRect rect = view.frame;// 保存View原有的frame.
    rect.origin.y += keyboardHeight;//y減去鍵盤的高度
    view.frame = rect;//把最新的frame賦值給view
    [UIView commitAnimations];
     */
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    NSLog(@"%@",NSStringFromCGSize(textView.contentSize));
    if ([text isEqual:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}
- (void)textViewDidChange:(UITextView *)textView {
    //給輸入框的高度設置限值為80
    if (textView.contentSize.height >= 80) {
        return;
    }
    textView.autoresizingMask = UIViewAutoresizingFlexibleHeight; //設置textView的自適應高度,改變自身高度,上下邊框和父視圖的間距保持不變
    UIView *view = (UIView *)[self.view viewWithTag:100];
    CGRect frame = view.frame;
    frame.size.height = textView.contentSize.height;
    frame.origin.y = 568 - textView.contentSize.height;
    view.frame = frame;

}

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

聂拉木县| 拜城县| 绍兴市| 桐庐县| 遂平县| 利辛县| 新蔡县| 枣强县| 南开区| 镇康县| 罗山县| 保亭| 桃源县| 三门县| 宽甸| 梁河县| 宁国市| 府谷县| 玉龙| 丽水市| 竹山县| 体育| 安吉县| 沂水县| 九龙坡区| 盐津县| 高要市| 兴仁县| 岑巩县| 永登县| 承德市| 卓尼县| 和政县| 仁化县| 青浦区| 贡山| 英德市| 济南市| 南昌县| 延安市| 阜新市|