91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

彈出鍵盤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

乌拉特中旗| 荆门市| 泰宁县| 自治县| 中西区| 永寿县| 洱源县| 松潘县| 东丽区| 宜良县| 隆安县| 大城县| 尚义县| 新田县| 成武县| 河间市| 菏泽市| 邵阳县| 贡嘎县| 陈巴尔虎旗| 渑池县| 日喀则市| 霍林郭勒市| 通江县| 桦甸市| 东安县| 汝南县| 栾川县| 马尔康县| 岑巩县| 蒙阴县| 抚松县| 古浪县| 丰都县| 都昌县| 固镇县| 临汾市| 县级市| 莲花县| 清镇市| 额尔古纳市|