iOS get Keyboard Window - ios

So in iOS 7 I always got the Keyboard Window like this:
- (UIView *)keyboardView
{
UIWindow* tempWindow;
//Because we cant get access to the UIKeyboard throught the SDK we will just use UIView.
//UIKeyboard is a subclass of UIView anyways
UIView* keyboard;
NSLog(#"windows %d", [[[UIApplication sharedApplication]windows]count]);
//Check each window in our application
for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; c ++)
{
//Get a reference of the current window
tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
//Get a reference of the current view
for(int i = 0; i < [tempWindow.subviews count]; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
NSLog(#"view: %#, on index: %d, class: %#", [keyboard description], i, [[tempWindow.subviews objectAtIndex:i] class]);
if([[keyboard description] hasPrefix:#"(lessThen)UIKeyboard"] == YES)
{
//If we get to this point, then our UIView "keyboard" is referencing our keyboard.
return keyboard;
}
}
for(UIView* potentialKeyboard in tempWindow.subviews)
// if the real keyboard-view is found, remember it.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
if([[potentialKeyboard description] hasPrefix:#"<UILayoutContainerView"] == YES)
keyboard = potentialKeyboard;
}
else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
if([[potentialKeyboard description] hasPrefix:#"<UIPeripheralHost"] == YES)
keyboard = potentialKeyboard;
}
else {
if([[potentialKeyboard description] hasPrefix:#"<UIKeyboard"] == YES)
keyboard = potentialKeyboard;
}
}
NSLog(#"view: %#, on index: %d", [keyboard description]);
return keyboard;
}
But in the iOS 8 beta 1 & 2 the window/view that is returned is the main App window. Any idea what is the the problem in my code? On my test device with iOS 7 it works great...

I also had this problem and found the solution.
Below is the code which will work for iOS 8.0 and also for below versions.
I have tested it on iOS 7 and 8.0 (Xcode Version 6.0.1)
- (void)addButtonToKeyboard
{
// create custom button
self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.doneButton.frame = CGRectMake(0, 163+44, 106, 53);
self.doneButton.adjustsImageWhenHighlighted = NO;
[self.doneButton setTag:67123];
[self.doneButton setImage:[UIImage imageNamed:#"doneup1.png"] forState:UIControlStateNormal];
[self.doneButton setImage:[UIImage imageNamed:#"donedown1.png"] forState:UIControlStateHighlighted];
[self.doneButton addTarget:self action:#selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
int windowCount = [[[UIApplication sharedApplication] windows] count];
if (windowCount < 2) {
return;
}
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i = 0 ; i < [tempWindow.subviews count] ; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard found, add the button
if([[keyboard description] hasPrefix:#"<UIPeripheralHost"] == YES){
UIButton* searchbtn = (UIButton*)[keyboard viewWithTag:67123];
if (searchbtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard)
[keyboard addSubview:self.doneButton];
}//This code will work on iOS 8.0
else if([[keyboard description] hasPrefix:#"<UIInputSetContainerView"] == YES){
for(int i = 0 ; i < [keyboard.subviews count] ; i++)
{
UIView* hostkeyboard = [keyboard.subviews objectAtIndex:i];
if([[hostkeyboard description] hasPrefix:#"<UIInputSetHost"] == YES){
UIButton* donebtn = (UIButton*)[hostkeyboard viewWithTag:67123];
if (donebtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard)
[hostkeyboard addSubview:self.doneButton];
}
}
}
}
}
>
-(void) removedSearchButtonFromKeypad{
int windowCount = [[[UIApplication sharedApplication] windows] count];
if (windowCount < 2) {
return;
}
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
for(int i = 0 ; i < [tempWindow.subviews count] ; i++)
{
UIView* keyboard = [tempWindow.subviews objectAtIndex:i];
if([[keyboard description] hasPrefix:#"<UIPeripheralHost"] == YES){
[self removeButton:keyboard];
}else if([[keyboard description] hasPrefix:#"<UIInputSetContainerView"] == YES){
for(int i = 0 ; i < [keyboard.subviews count] ; i++)
{
UIView* hostkeyboard = [keyboard.subviews objectAtIndex:i];
if([[hostkeyboard description] hasPrefix:#"<UIInputSetHost"] == YES){
[self removeButton:hostkeyboard];
}
}
}
}
}
-(void) removeButton:(UIView*)keypadView{
UIButton* donebtn = (UIButton*)[keypadView viewWithTag:67123];
if(donebtn){
[donebtn removeFromSuperview];
donebtn = nil;
}
}
Hope this helps.

What i use to get the window for the keyboard is
- (void)findKeyboardWindow
{
for (UIWindow *window in [[UIApplication sharedApplication] windows])
{
if ([NSStringFromClass([window class]) isEqualToString:#"UITextEffectsWindow"])
{
_keyboardWindow = window;
break;
}
}
}
From my logs on iOS8 this contains one view
UIInputSetContainerView: 0x190d4430; frame = (0 0; 320 568); autoresize = W+H; layer = CALayer: 0x190d4630
Which contains another view
UIInputSetHostView: 0x190d4820; frame = (0 352; 320 216); layer = CALayer: 0x190d49c0
Since those dimensions are 216.0f height i guess that is the keyboard.
Was this what you where looking for?

On iOS 13, we can get keyboard window like this:
let windows = UIApplication.shared.windows
if let keyboardWindow = windows.first(where: { NSStringFromClass($0.classForCoder) == "UIRemoteKeyboardWindow" }) {
return
}

In the first iOS 8 beta, the system keyboard is the UIInputSetHostView subview of the UIInputSetContainerView subview of one of the application windows.

Related

Xcode: Remove an array of textiews from screen

I'm currently adding 5 textviews onto the viewcontroller programatically inside the viewDidLoad method.
for (int i = 0; i < 5; i++) {
//Add 5 textviews
UITextView *reqTV = [[UITextView alloc] initWithFrame:CGRectMake(30,30,250,50)];
reqTV.text = #"This is a textview";
[self.view addSubview:reqTV];
}
If later, I want to delete (not hide) these 5 textviews with a button click, how would I do that?
I have thought of using this, but am not sure how to call all 5 textviews to delete them.
- (void)removeTextViewButton:(id)sender {
[reqTV removeFromSuperview]; //remove textview
}
Thank you.
I see two easy ways:
You can save your textViews inside array as ivar of your controller.
And later remove each textView in array.
for (int i = 0; i < 5; i++) {
...
[textViews addObject: reqTV];
...
}
- (void)removeTextViewButton:(UIButton *)sender {
[textViews makeObjectsPerformSelector:#selector(removeFromSuperview)];
}
2. Assign static tag for each textView:
for (int i = 0; i < 5; i++) {
...
reqTV.tag = 1001; // for example
}
- (void)removeTextViewButton:(UIButton *)sender {
NSArray *subs = [NSArray arrayWithArray: self.view.subviews];
for (UIView *sub in subs) {
if (sub.tag == 1001) {
[sub removeFromSuperview];
}
}
}
Used code below to remove UITextViews:
- (void)removeTextViewButton:(id)sender {
NSArray *reqTVViews = [NSArray arrayWithArray: self.view.subviews];
for (UIView *tvView in reqTVViews) {
if ([tvView isKindOfClass:[UITextView class]]) {
[tvView removeFromSuperview];
}
}
}
When you are adding UITextFields on viewController use tag value to uniquely identify each textField.
You can store each tag value in an array for further use, eg.
#property (nonatomic, strong) NSMutableArray *tagArray;
NSMutableArray *tagArray = [NSMutableArray array];
for (int i = 101; i <= 105; i++ ) {
UITextField *txt = [UITextField alloc] init]; //for eg.
...
...
txt.tag = i;
[arr addObject:[NSNumber numberWithInt:i]];
[self.view addSubView:txt];
}
When you want to delete any of the textField or all then...
UIView *view = [self.view viewWithTag:<tag value>];
[view removeFromSuperview];
eg.
for (int i = 0; i < tagArray.count; i++) {
NSInteger tag = [[arr objectAtIndex:i] intValue];
UITextField *txt = (UITextField *)[self.view viewWithTag:tag];
[txt removeFromSuperview];
}
You can remove all subview in one go
- (void)removeTextViewButton:(id)sender
{
for (UIView *subview in views.subviews)
{
[subview removeFromSuperview];
}
}
Happy Coding.. :)

Why UIButton's selector method is not called?

My iPhone has iOS8. I'd like to add DONE button on the UIKeyboardTypeNumberPad. DONE is displayed on the left side empty button. But the selector method doneButtonClicked is not called when I touch(press) DONE. My code is below. What is wrong with the code?
- (void)viewWillAppear:(BOOL)animtated {
// Register the observer for the keyboardWillShow event
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
}
- (void)viewWillDisappear:(BOOL)animtated {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)keyboardWillShow:(NSNotification *)notification {
// create custom button
if (!self.doneButton)
{
self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.doneButton addTarget:self action:#selector(doneButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
self.doneButton.adjustsImageWhenHighlighted = NO;
[self.doneButton setTitle:#"DONE" forState:UIControlStateNormal];
[self.doneButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]];
[self.doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self.doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
// locate keyboard view
if ([[[UIApplication sharedApplication] windows] count] <= 1) return;
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard found, add the button
if ([[keyboard description] hasPrefix:#"<UIPeripheralHost"] == YES)
{
BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);
self.doneButton.frame = CGRectMake(((isPortrait)?0:-1),((int) (keyboard.frame.size.height*3)/4) + ((isPortrait)?0:1),(int) keyboard.frame.size.width/3-1, (isPortrait)?60:40);
[keyboard addSubview:self.doneButton];
}
//This code will work on iOS 8.0
else if([[keyboard description] hasPrefix:#"<UIInputSetContainerView"] == YES)
{
for(int i = 0 ; i < [keyboard.subviews count] ; i++)
{
UIView* hostkeyboard = [keyboard.subviews objectAtIndex:i];
if([[hostkeyboard description] hasPrefix:#"<UIInputSetHost"] == YES)
{
BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);
self.doneButton.frame = CGRectMake(((isPortrait) ? 0 : -1),((int) (hostkeyboard.frame.size.height*3)/4) + ((isPortrait) ? 0 : 1),(int) hostkeyboard.frame.size.width/3-1, (isPortrait) ? 60 : 40);
[hostkeyboard addSubview:self.doneButton];
}
}
}
else{}
}
}
- (void)doneButtonClicked:(id)sender{
[self.heightUpdateTextField resignFirstResponder];
}
Try this out. This method works for me for iOS 6, 7 & 8:
- (void)keyboardWillShow:(NSNotification *)iNotification
// If there's no keyboard yet, don't do anything
if ([[[UIApplication sharedApplication] windows] count] < 2) {
return;
}
UIWindow *keyboardWindow = [[UIApplication sharedApplication] windows][1];
// Create new dismiss keyboard button
UIButton *aDismissKeyboardButton = [UIButton buttonWithType:UIButtonTypeCustom];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"8.3")) {
aDismissKeyboardButton.frame = CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - 53, [[UIScreen mainScreen] bounds].size.width / 3, 53);
} else {
aDismissKeyboardButton.frame = CGRectMake(0, 163, 106, 53);
}
aDismissKeyboardButton.adjustsImageWhenHighlighted = FALSE;
[aDismissKeyboardButton setExclusiveTouch:YES];
UIImage *aDismissKeyboardButtonImageNormal;
UIImage *aDismissKeyboardButtonImageHighlighted;
aDismissKeyboardButtonImageNormal = [UIImage imageNamed:#"myImage.png"];
aDismissKeyboardButtonImageHighlighted = [UIImage imageNamed:#"myImageHighLighted.png"];
[aDismissKeyboardButton setImage:aDismissKeyboardButtonImageNormal forState:UIControlStateNormal];
[aDismissKeyboardButton setImage:aDismissKeyboardButtonImageHighlighted forState:UIControlStateHighlighted];
SEL aDoneButtonSelector = NSSelectorFromString(#"doneButtonPressed");
[aDismissKeyboardButton addTarget:iDelegate action:aDoneButtonSelector forControlEvents:UIControlEventTouchUpInside];
// Locate keyboard view and add button
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"8.3")) {
for (UIWindow *window in [[UIApplication sharedApplication] windows]) {
if ([[window description] hasPrefix:#"<UITextEffectsWindow"]) {
[window addSubview:aDismissKeyboardButton];
return;
}
}
} else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"8.0")) {
for (UIView *aSubview in [[keyboardWindow.subviews objectAtIndex:0] subviews]) {
if ([[aSubview description] hasPrefix:#"<UIInputSetHost"]) {
[aSubview addSubview:aDismissKeyboardButton];
return;
}
}
} else {
NSString *keyboardPrefix = SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"6.0") ? #"<UIPeripheralHost" : #"<UIKeyboard";
for (UIView *aSubView in keyboardWindow.subviews) {
if ([[aSubView description] hasPrefix:keyboardPrefix]) {
[aSubView addSubview:aDismissKeyboardButton];
return;
}
}
}
}
Here, I have defined a macro to check system version like this:
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
sorry for bad english.
I was copied your code earlier to check, what the mistake, after few changes its working good But the Frame of done Button is deferent tha t you can change according to your desire, let check edited code..
- (void)viewWillAppear:(BOOL)animtated {
// Register the observer for the keyboardWillShow event
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
}
- (void)viewWillDisappear:(BOOL)animtated {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)keyboardWillShow:(NSNotification *)notification {
// create custom button
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
[doneButton addTarget:self action:#selector(doneButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setTitle:#"DONE" forState:UIControlStateNormal];
[doneButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]];
[doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
// locate keyboard view
if ([[[UIApplication sharedApplication] windows] count] <= 1) return;
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard found, add the button
if ([[keyboard description] hasPrefix:#"<UIPeripheralHost"] == YES)
{
BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);
doneButton.frame = CGRectMake(((isPortrait)?0:-1),((int) (keyboard.frame.size.height*3)/4) + ((isPortrait)?0:1),(int) keyboard.frame.size.width/3-1, (isPortrait)?60:40);
[keyboard addSubview:doneButton];
}
//This code will work on iOS 8.0
else if([[keyboard description] hasPrefix:#"<UIInputSetContainerView"] == YES)
{
for(int i = 0 ; i < [keyboard.subviews count] ; i++)
{
UIView* hostkeyboard = [keyboard.subviews objectAtIndex:i];
if([[hostkeyboard description] hasPrefix:#"<UIInputSetHost"] == YES)
{
BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);
doneButton.frame = CGRectMake(((isPortrait) ? 0 : -1),((int) (hostkeyboard.frame.size.height*3)/4) + ((isPortrait) ? 0 : 1),(int) hostkeyboard.frame.size.width/3-1, (isPortrait) ? 60 : 40);
[hostkeyboard addSubview:doneButton];
}
}
}
else{}
}
}
- (void)doneButtonClicked:(id)sender{
[self->cityTxt resignFirstResponder]; //cityTxt is my textfield
}
its work for me, hope it works for you also.

How to remove top bar of the keyboard in ios 7

In my program I use UIWebView with editable div for the Rich text editor. I need to remove top bar of the keyboard.
I used below code - it removes only next/previous buttons
I want to remove full top bar.
- (void)removeBar {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
for (UIView *possibleFormView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:#"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:#"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}
I found the solution for iOS 8. You can check it here: [ iOS 8 - Remove Previous/Next/Done UIKeyboard Toolbar inside a UIWebView][1]
You may try and improve this. try call this function inside Your UIKeyboardDidShowNotification event handler.
Hope this helps...
This is the level of views in accessory:
(UIWebFormAccessory) -> (UIToolbar) -> (UIImageView,UIToolbarButton,UIToolbarButton)
-(void) removeKeyboard {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual : [UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
// Locate UIWebFormView.
for (UIView *possibleFormView in [keyboardWindow subviews]) {
if ([[possibleFormView description] hasPrefix : #"<UIInputSetContainerView"]) {
for (UIView* peripheralView in possibleFormView.subviews) {
for (UIView* peripheralView_sub in peripheralView.subviews) {
// hides the backdrop (iOS 8)
if ([[peripheralView_sub description] hasPrefix : #"<UIKBInputBackdropView"] && peripheralView_sub.frame.size.height == 44) {
[[peripheralView_sub layer] setOpacity : 0.0];
}
// hides the accessory bar
if ([[peripheralView_sub description] hasPrefix : #"<UIWebFormAccessory"]) {
for (UIView* UIInputViewContent_sub in peripheralView_sub.subviews) {
CGRect frame1 = UIInputViewContent_sub.frame;
frame1.size.height = 0;
peripheralView_sub.frame = frame1;
UIInputViewContent_sub.frame = frame1;
[[peripheralView_sub layer] setOpacity : 0.0];
}
CGRect viewBounds = peripheralView_sub.frame;
viewBounds.size.height = 0;
peripheralView_sub.frame = viewBounds;
}
}
}
}
}
}
There is a solution for this here.
That answer includes a function called removeKeyboardTopBar which should be called on the UIKeyboardWillShowNotification.
Listen to the notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
On the notification, call the function after a delay. The delay is necessary to make sure that the objects exist before the function runs (since we are calling this on keyboard will show, not keyboard did show).
- (void)keyboardWillShow:(NSNotification*) notification {
[self performSelector:#selector(removeKeyboardTopBar) withObject:nil afterDelay:0];
}
From what I can tell, it looks like the keyboard has an added inputAccessoryView to the top of it. Otherwise, I'm not certain why it is appearing. Anyways, if that is the case then whatever you assign firstResponder to set their inputAccessoryView to nil:
someObjectWithFirstResponder.inputAccessoryView = nil;
EDIT: Looks like the UIWebView sets the inputAccessoryView itself, but if it is actually receiving firstResponder then you should be able to override the inputAccessoryView. If setting it to nil causing it to default back to the inputAccessoryView that you are trying to remove, then you might try setting it to an empty view:
someObjectWithFirstResponder.inputAccessoryView = [UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
EDIT This method does not work in iOS 8.0 and greater.

Can I count up whole of views to check performance?

Memory use and cpu time can be available like below.
Programmatically retrieve memory usage on iPhone
And also i'd like to know the number of views to check performance? Is it possible?
I solved myself. call countViewsInApp. thx.
+ (int)countViewsInApp {
int num = 0;
for (UIWindow *window in [[UIApplication sharedApplication] windows]) {
for (UIView *aView in [window subviews]) {
num++; // parent
num += [self countSubviews:aView];
}
}
return num;
}
+ (int)countSubviews:(UIView *)view {
int num = 0;
for (UIView *subview in [view subviews]) {
num++;
if ([[subview subviews] count] > 0) {
num += [self countSubviews:subview];
}
}
return num;
}
You can do like that:
- (NSUInteger *)countSubviewsInViewСonsideringView:(UIView *)view {
NSUInteger subviewsCount = 1; // the current view
for (UIView *subView in view.subviews) {
subviewsCount += [self countSubviewsInViewСonsideringView:subView]
}
return subviewsCount;
}
somewhere in code:
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
NSUInteger count = [self countSubviewsInViewСonsideringView:window];

can't remove navigation item in QLPreviewController in iOS 6

i subclassed QLPreviewController and used
[[self navigationItem] setRightBarButtonItem:nil];
but the navigationItem is only removed in iOS 5, not iOS6
i managed to do it by creating a timer to check for the navigation item and remove it
Here is the code:
[self inspectSubviewsForView:self.view];
- (void)inspectSubviewsForView:(UIView *)view
{
for (UIView *subview in view.subviews)
{
NSLog(#"class detected %#",[subview description]);
if ([subview isKindOfClass:[UINavigationBar class]])
{
UINavigationBar *bar = (UINavigationBar *)subview;
if ([[bar items] count] > 0)
{
UINavigationItem *navItem = [[bar items] objectAtIndex:0];
[navItem setRightBarButtonItem:nil];
{
}
if ([subview isKindOfClass:[UIView class]] && [[subview subviews] count] > 0)
{
[self inspectSubviewsForView:subview];
}
}
}
[self inspectSubviewsForView:subview];
}
}
Simple solution for this is add one dummy view to current viewController and Add QLPreviewController.view to dummy view .
previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
previewController.delegate = self;
previewController.currentPreviewItemIndex = 0;
[self.ContentView addSubview:previewController.view];
- (IBAction)removeQPView:(id)sender {
[previewController.view removeFromSuperview];
}

Resources