objective c - iOS UIScrollView scrolling detection -
i'm developing kind of uitextview
copy customizations. need implement selection cursors (see screenshot of original uitextview
below)
as discovered debug view hierarchy
apple developers draw these dots on separate window avoid clipping, , when uiscrollview
starts dragging move these dots inside uitextview
, when stops dragging move separate window. problem approach how can detect when of textview
superview
's uiscrollview
, start/end scrolling? setting delegate each of uiscrollview
-type superviews
looks bad , bring lot of headache, cause need manage several delegates if needed (and detect there change). ideas?
/* in viewdidload or ever create uitextview call :[self checkparentviewoftextview:textfield]; */ -(void)checkparentviewoftextview:(uitextview*)txv { if ([txv.superview iskindofclass:[uiscrollview class]]) { // check if superview if uiscrollview uiscrollview *superscroll =(uiscrollview*) txv.superview; superscroll.delegate = self;// in order call delegate methods below superscroll.tag = 5; // set tag access current scrollview @ these delegate methods } } -(void)scrollviewdidscroll:(uiscrollview *)scrollview{ //any scrollview did begin scrolling if (scrollview.tag == 5) { //actions scrollview } } -(void)scrollviewdidenddecelerating:(uiscrollview *)scrollview{ //any scrollview did end scrolling if (scrollview.tag == 5) { //actions scrollview } }
Comments
Post a Comment