कैसे स्थानांतरित करें UITextView कुछ मूल्य दर्ज करना प्रारंभ करते समय ऊपर और नीचे। टेक्स्टफिल्ड की तरह हम इसकी प्रतिनिधि विधि का उपयोग करते हैं। UITextView के मामले में क्या करना है?कुंजीपटल मौजूद होने पर UITextView को कैसे स्थानांतरित करें
उत्तर
संपादन पूरा दृश्य मैं सुझाव है कि आप this guide पर एक नज़र लेने के लिए
- (void)textViewDidBeginEditing:(UITextView *)textView
{
[self animateTextView: YES];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
[self animateTextView:NO];
}
- (void) animateTextView:(BOOL) up
{
const int movementDistance =heightKeyboard; // tweak as needed
const float movementDuration = 0.3f; // tweak as needed
int movement= movement = (up ? -movementDistance : movementDistance);
NSLog(@"%d",movement);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.inputView.frame, 0, movement);
[UIView commitAnimations];
}
मुझे आशा है कि यह आप में मदद मिलेगी ...
हम, आपको एनीमेशन के लिए ब्लॉक का उपयोग करना चाहिए, आईओएस 4 – Beuj
के बाद से आपकी विधि को निराश किया गया है, मुझे इस कोड के साथ बहुत से मुद्दों का सामना करना पड़ा। 'self.inviewView.frame' को 'self.view.frame' के साथ बदलकर हल किया गया। – Rajesh
जब आप स्क्रॉलव्यू के साथ समाधान का उपयोग नहीं कर सकते हैं, तो यह सबसे आसान और सबसे अच्छा तरीका है –
#define kOFFSET_FOR_KEYBOARD 80.0
-(void)keyboardWillShow {
// Animate the current view out of the way
if (self.view.frame.origin.y >= 0)
{
[self setViewMovedUp:YES];
}
else if (self.view.frame.origin.y < 0)
{
[self setViewMovedUp:NO];
}
}
-(void)keyboardWillHide {
if (self.view.frame.origin.y >= 0)
{
[self setViewMovedUp:YES];
}
else if (self.view.frame.origin.y < 0)
{
[self setViewMovedUp:NO];
}
}
-(void)textFieldDidBeginEditing:(UITextField *)sender
{
if ([sender isEqual:mailTf])
{
//move the main view, so that the keyboard does not hide it.
if (self.view.frame.origin.y >= 0)
{
[self setViewMovedUp:YES];
}
}
}
//method to move the view up/down whenever the keyboard is shown/dismissed
-(void)setViewMovedUp:(BOOL)movedUp
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3]; // if you want to slide up the view
CGRect rect = self.view.frame;
if (movedUp)
{
// 1. move the view's origin up so that the text field that will be hidden come above the keyboard
// 2. increase the size of the view so that the area behind the keyboard is covered up.
rect.origin.y -= kOFFSET_FOR_KEYBOARD;
rect.size.height += kOFFSET_FOR_KEYBOARD;
}
else
{
// revert back to the normal state.
rect.origin.y += kOFFSET_FOR_KEYBOARD;
rect.size.height -= kOFFSET_FOR_KEYBOARD;
}
self.view.frame = rect;
[UIView commitAnimations];
}
- (void)viewWillAppear:(BOOL)animated
{
// register for keyboard notifications
[[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
{
// unregister for keyboard notifications while not visible.
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillHideNotification
object:nil];
}
इस कोड की कोशिश .....
मैं फ्रेम बदलकर किया था।
-(void)textViewDidBeginEditing:(UITextView *)textView{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:viewMsg cache:YES];
viewMsg.frame = CGRectMake(10, 50, 300, 200);
[UIView commitAnimations];
NSLog(@"Started editing target!");
}
-(void)textViewDidEndEditing:(UITextView *)textView
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:viewMsg cache:YES];
viewMsg.frame = CGRectMake(10, 150, 300, 200);
[UIView commitAnimations];
}
यहां एक नमूना कोड है जो आपके लिए स्वचालित रूप से कीबोर्ड को संभालेगा। Keyboard avoiding
आप tableview उपयोग कर रहे हैं तो अपने tableView TPKeyboardAvoidingTableView
का एक उपवर्ग होना चाहिए और यदि आप scrollview उपयोग कर रहे हैं तो अपने scrollview TPKeyboardAvoidingScrollView
का एक उपवर्ग होना चाहिए। और यह लाइब्रेरी स्वचालित रूप से आपके लिए कीबोर्ड हैंडलिंग करेगी।
ऊपर आ जाएगा और पूर्ण संपादन के बाद नीचे ले जाने के करते हैं ...
विशेष रूप से अनुभाग: कुंजीपटल के तहत स्थित सामग्री को स्थानांतरित करना। मैंने इस दृष्टिकोण का सफलतापूर्वक कई बार उपयोग किया है।
- 1. कस्टम कुंजीपटल iphone, UITextView
- 2. कुंजीपटल ऊपर होने पर स्क्रॉलव्यू समायोजित करें
- 3. उमोडल प्रस्तुतिफॉर्मशीट। कीबोर्ड प्रकट होने पर UITextView ऊंचाई को समायोजित कैसे करें
- 4. UITextView पर कीबोर्ड को अक्षम कैसे करें?
- 5. मौजूद होने पर ट्रिगर ड्रॉप करें और
- 6. कुंजीपटल
- 7. मौजूद होने पर पंक्ति हटाएं
- 8. टैग को कैसे स्थानांतरित करें?
- 9. जावास्क्रिप्ट: कुंजीपटल घटनाओं को डीबग कैसे करें
- 10. संकलन-समय में इंटरफ़ेस मौजूद होने पर परीक्षण कैसे करें?
- 11. कुंजीपटल दिखाए जाने पर UIWebView सामग्री को स्थानांतरित करने के लिए सेट करें
- 12. UITextView पर लंबी प्रेस को कैसे रोकें?
- 13. UITextView पर टेक्स्ट छाया कैसे लागू करें?
- 14. कैस्परजेएस में चयनकर्ता मौजूद होने पर परीक्षण कैसे करें?
- 15. ftp निर्देशिका मौजूद होने पर पायथन जांच कैसे करें?
- 16. कुंजीपटल
- 17. mysql में मौजूद होने पर कॉलम को कैसे छोड़ें?
- 18. UITextView पर इलिप्स को कैसे जोड़ा जाए?
- 19. QSplitter को कैसे स्थानांतरित करें?
- 20. स्वामित्व स्थानांतरित होने पर CA2000 चेतावनी से कैसे छुटकारा पाएं?
- 21. कैसे कुंजीपटल
- 22. ffmpeg मौजूद होने पर आउटपुट फ़ाइल ओवरराइड
- 23. jQuery-UI स्लाइडर - कुंजीपटल इनपुट को अक्षम कैसे करें?
- 24. MVC3 TempData मौजूद न होने पर बटन
- 25. UITextView
- 26. एनीमेशन: दृश्य लोड होने पर यूआईबटन को दाएं से बाएं स्थानांतरित करने के लिए कैसे करें?
- 27. एप्लेट व्यूअर विंडो को कैसे स्थानांतरित करें?
- 28. स्थान पर बहुआयामी सरणी कैसे स्थानांतरित करें
- 29. सर्कल प्रक्षेपवक्र पर uiview कैसे स्थानांतरित करें?
- 30. कुंजीपटल खुले होने पर एनिमेटिंग लेआउट आकार बदलें
'textFieldDidBecomeActive'> तदनुसार टेक्स्ट फ़ील्ड को ले जाएं। –
http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present कृपया यह लिंक देखें –
क्या खोज करना मुश्किल है? यहां तक कि यदि यह है, साइडबार देखें: यह आपको संबंधित प्रश्न दिखाता है। – Abizern