ios - UISearchDisplayController UISearchBar Animation in a UIScrollView under UIPageControl -
it's tough bug squash, objc-fu beginner , confidence crashing longer pretty bug...
the app required have view (let's phone call mainview
) uipagecontrol
, uiscrollview
in order have 2 views scrollable horizontally. hence have implemented adding:
// added on viewdidload... [self addchildviewcontroller:[self.storyboard instantiateviewcontrollerwithidentifier:@"vc1"]]; [self addchildviewcontroller:[self.storyboard instantiateviewcontrollerwithidentifier:@"vc2"]]; // farther processing of kid view controllers... self.scrollview.pagingenabled = yes; (nsuinteger = 0; < [self.childviewcontrollers count]; i++) { uiviewcontroller *controller = [self.childviewcontrollers objectatindex:page]; cgrect frame = self.scrollview.frame; frame.origin.x = frame.size.width * page; frame.origin.y = 0; controller.view.frame = frame; [self.scrollview addsubview:controller.view]; } // expanding scroll view's content size scrolling... self.scrollview.contentsize = cgsizemake( scrollview.frame.size.width * [self.childviewcontrollers count], scrollview.frame.size.height);
note mainview
equipped uisearchdisplaycontroller
having uisearchbar
hidden offscreen. (not sure if info vital.)
the problem in sec kid view controller identifier vc2 equipped uisearchdisplaycontroller
having uisearchbar
, , when search bar dismisses on end searching, animation how create vc2's uisearchbar
reposition in cgrect(0, 0, 320, 40)
of mainview
instead of vc2. hence vc2's uisearchbar
"warped" vc1.
first effort solve containing each kid view controller in view hoping cgrect(0, 0, 320, 40)
of vc2's uisearchbar
remain in vc2, no avail:
for (nsuinteger = 0; < [self.childviewcontrollers count]; i++) { uiviewcontroller *controller = [self.childviewcontrollers objectatindex:page]; cgrect frame = self.scrollview.frame; frame.origin.x = frame.size.width * page; frame.origin.y = 0; //controller.view.frame = frame; uiview *container = [[uiview alloc] initwithframe:frame]; [container addsubview:controller.view]; [self.scrollview addsubview:container]; }
somehow guessing when vc2's uisearchdisplaycontroller
animates it's uisearchbar
frame
uses 1 of self.uiscrollview
not sure.
could please shed lite on bug , fire death please? it's in ios7
main view ------------------- | vc1 | vc2 ------------------------------------- | |_________________| <- search bar (this 'warped' vc1 @ same | | | position on end editing) | | | | | | | | | | | | | | | | | | | | | | | | -------------------------------------
found solution, weird, works, got thought searchbar disappears headerview in ios 7 after noticing memory address of uisearchbar
's superview changed on end search.
the next code snippet added of delegated methods possible, namely viewwillappear
, searchdisplaycontrollerwillendsearch:
, searchdisplaycontrollerdidendsearch:
:
if (self.searchdisplaycontroller.searchbar.superview != self.searchdisplaycontroller.searchcontentscontroller.view) { [self.searchdisplaycontroller.searchbar removefromsuperview]; [self.searchdisplaycontroller.searchcontentscontroller.view addsubview:self.searchdisplaycontroller.searchbar]; }
will take reply still should there wrong share. give thanks much.
ios uiscrollview uisearchbar uisearchdisplaycontroller uipagecontrol
No comments:
Post a Comment