ios - Scrolling of scrollView with TextView -


i'm having scrollview contains 1 uiimageview on top , uitextview scrollingenabled = no , want scroll scrollview @ position type.

- (void)createscrollview{ //tpkeyboardavoidingscrollview *scrollview = [[tpkeyboardavoidingscrollview alloc]init]; uiscrollview *scrollview = [[uiscrollview alloc]init]; //[self.view insertsubview:scrollview belowsubview:_mediaselectionview]; [self.view addsubview: scrollview]; [scrollview settranslatesautoresizingmaskintoconstraints: no]; self.scrollview = scrollview; scrollview.showshorizontalscrollindicator = no; scrollview.showsverticalscrollindicator = no; scrollview.bounceszoom = no; scrollview.alwaysbouncevertical = yes; scrollview.clipstobounds = yes; self.automaticallyadjustsscrollviewinsets = yes; nslayoutconstraint *scrollviewtop = [nslayoutconstraint                                      constraintwithitem: scrollview                                      attribute: nslayoutattributetop                                      relatedby: nslayoutrelationequal                                      toitem: self.navigationbarbgview                                      attribute: nslayoutattributebottom                                      multiplier: 1 constant:0.0                                      ]; nslayoutconstraint *scrollviewleading = [nslayoutconstraint                                          constraintwithitem: scrollview                                          attribute: nslayoutattributeleading                                          relatedby: nslayoutrelationequal                                          toitem: self.view                                          attribute: nslayoutattributeleading                                          multiplier: 1 constant:0.0                                          ];  nslayoutconstraint *superviewtraling = [nslayoutconstraint                                         constraintwithitem: self.view                                         attribute: nslayoutattributetrailing                                         relatedby: nslayoutrelationequal                                         toitem: scrollview                                         attribute: nslayoutattributetrailing                                         multiplier: 1 constant:0.0                                         ];  nslayoutconstraint *bottomlayoutguidetop = [nslayoutconstraint                                             constraintwithitem:self.view                                             attribute: nslayoutattributebottom                                             relatedby: nslayoutrelationequal                                             toitem: scrollview                                             attribute: nslayoutattributebottom                                             multiplier: 1 constant:0.0                                             ]; //add constrains. [self.view addconstraints: @[scrollviewtop , scrollviewleading , superviewtraling , bottomlayoutguidetop ]];  _contentview = [[uiview alloc]init];  [scrollview addsubview: _contentview]; [_contentview setconstraintflag]; [_contentview setfullwidth]; [_contentview settopfromparent:0]; 

}

- (void)createcommenttextview{     uitextview *textview = [[uitextview alloc]init];     textview.backgroundcolor = [uicolor clearcolor];     textview.textcolor = [uicolor colorwithr:67 g:83 b:83 a:1.0f];     textview.delegate = self;     textview.scrollenabled = no;             _commenttextview = textview;     [_textviewcontainer addsubview:textview]; 

}

-(void)updatecontentsize{ self.scrollview.contentsize = cgsizemake(self.scrollview.contentsize.width, self.contentview.frame.size.height); 

}

scrollview contains _contentview , contentview contains uitextview. textview height increases user types , _contentview's bottom equal bottom of textview.

use:
pod 'tpkeyboardavoiding' or
https://github.com/michaeltyson/tpkeyboardavoiding

pod 'animatedtextinput'
https://github.com/jobandtalent/animatedtextinput


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -