Friday, 15 May 2015

objective c - subview from UIWindow and sending it back to UIwindow -



objective c - subview from UIWindow and sending it back to UIwindow -

i have uiwebview loaded div, deed editor write. adding uiwebview sub view on uiwindow set frame equal total screen , hide uikeyboard, @ button method, need uiwebview uiwindow , sent uikeyboard. here code not working:

keyboardwindowframe= nil; (uiwindow *testwindow in [[uiapplication sharedapplication] windows]) { if (![[testwindow class] isequal:[uiwindow class]]) { keyboardwindowframe = testwindow; [webviewforediting setframe:cgrectmake(5, 63, 310, 400)]; [webviewforediting.scrollview setcontentsize:cgsizemake(310, 400)]; [keyboardwindowframe addsubview:webviewforediting]; break; } } - (ibaction)keyboardbuttonselected:(id)sender { [keyboardwindowframe sendsubviewtoback:webviewforediting]; //need send uiwebview uiwindow can write }

i think trying same thing , although question not particularly clear reply help.

it seems have view 'webviewforediting' want add together , bring in front end of keyboard. when click button want set view behind keyboard again.

i have tried using sendsubviewtoback code no joy.

in end though managed work using:

[[self view] exchangesubviewatindex: withsubviewatindex: ];

(credit goes sunny adapted question here)

i used next code below, switch between uiview , keyboard:

- (ibaction)togglebuttonpressed:(id)sender { uiwindow * window = [uiapplication sharedapplication].windows.lastobject; if (window.subviews.count == 1) { [window addsubview:_menuview]; } else { [window exchangesubviewatindex: 0 withsubviewatindex: 1]; } }

i working 2 views (_menuview , keyboard) means check how many subviews window has create sure add together _menuview once.

then easy exchange 2 views.

even if had more subviews in window sure utilize modified version of this. long none of other views alter places exchanging them switch same 2 views.

note: aside. not sure if code works if called when keyboard not first responder. variable window using lastly object in window, keyboard if has been made first responder. might need tweaking working @ other times.

objective-c uiwebview uiwindow

No comments:

Post a Comment