I've taken over development of an iPad app and am adding AdMob into it, this is all working correctly apart from one layout issue when the advert opens, I believe it may be to do with it opening from a modal window.
The advert opens with some content from the previous window infront of it, it covers the status bar, and leaves a space at the bottom about the same height as the status bar. I'm adding this advert in the same way I am the others, which work from...
GADAdSize customAdSize = GADAdSizeFromCGSize(CGSizeMake(300, 50));
adView = [[DFPBannerView alloc] initWithAdSize:customAdSize];
adView.adUnitID = #"xxxxxxxxxxxx";
adView.rootViewController = self;
[self.view addSubview:adView];
[adView setDelegate: self];
Any ideas how this can be fixed, without restructuring the app so the previous one isn't a modal window?
Are you hiding the status bar before you display the initial modal view? I know the click through modal for AdMob usually gets off-place if you do this.
Make sure you're also not doing anything else weird with positioning when you display your first modal.
Related
Background and Aim:
In my existing app, I'm trying to provide voice messaging feature to user. The idea is to optionally provide universal access of voice messaging from anywhere in the app to the user (inspired by facebook messages). I have had partial success so far in displaying my mini message dashboard and tap on which opens customized message (popover) view on both iPhone & iPad.
I added my mini dashboard subview on application keywindow and hence it's visible across (top of) all the views when navigating within the app.
[application.keyWindow addSubview:self.messageDashBoardVC.view];
This made it appear automatically (out of the box) on top of even the modal dialogs (mostly) in app presented like this..
[self presentViewController:modelVC animated:YES completion:nil]
Specific PROBLEM statement:
However..
On iPad when a view controller is presented modally with
modalPresentationStyle = UIModalPresentationFormSheet
or UIModalPresentationPageSheet
the mini dashboard hides behind the modal dialog (sheet). HOWEVER, I want user to access voice feature (mini dashboard & popover views) when working on these sheets.
My existing app uses a lot of such modal dialogs (sheets).
General Problem statement:
Is there any reusable component/source code available that does same thing because I think the orientation handling will also be a tricky/quite a work with my approach? Any other problem that you envisage with my approach?
I found some success to specific PROBLEM statement above:-
The modal view is presented (added) to the same window so I simply brought my mini dashboard view in front like this..
UIWindow *appDelegateWindow = [[[UIApplication sharedApplication] delegate] window];
UIView *miniView = (UIView *)[appDelegateWindow viewWithTag:12221]; // 12221 is tag of mini dashboard view.
[appDelegateWindow bringSubviewToFront:miniView];
However, I'm still looking forward to your expert opinion about my approach and open for alternative approach considering orientation and other potential challenges I might get with this approach.
Next up - I am working on bringing my custom popover view in front of modal sheet. As of now, tap on mini view opens the message popover but behind the modal sheet.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MALoginViewController *login=[[MALoginViewController alloc]initWithNibName:#"MALoginViewController" bundle:nil];
MANowPlayingViewController *nav=[[MANavigationController alloc]initWithRootViewController:home];
[self.window setRootViewController:nav];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
here MANowPlayingViewController is class of UINavigationController..so you have to create separate class for UINavigationController...then set that into Window RootviewController..
whatever you give in that UINavigationController class will display all pages in your app..you can handle your all common codes inside this class..For example if you add UIButton on that NavigationBar ,it will display in all classes...
thanks..
actually I'm quite new with Xcode and couldn't find the answer to the following two questions by a google search:
to make it short: I'm working on an iPad app that displays proposals. For this purpose you should choose a proposal from the table in MasterView and then see the details in the DetailsView in landscape mode (but without the MasterView on the Spitscreen).
So when the app starts in landscape mode, I wanna see directly the first proposal full screen on the DetailsView. And when I tap onto the screen the MasterView should popup/unhide with the other proposals in the table. Is this possible?
I wanna display the PDFs in a WebView like in iBooks. That means that the navigation bar is hidden and only when I tap onto the screen the navigation bar should appear at the top of the screen.
I'm kind of sure this questions have been solved somewhere but I couldn't find anything by search so I hope you can help me anyway :-)
Thanks in Advance!
Q1: Use can use one of many methods to present a view (look up under Apple's doc on UIViewController under "Presenting Another View Controller's Content" heading). Two that I have used are: – presentModalViewController:animated: and – presentViewController:animated:completion: (the latter is the latest addition in iOS 5.0)
So let's say you have a detail controller called MyDetailViewController, in your Master View Controller's implementation file (the .m file), under viewDidLoad method, you would do some thing like this to present it as a full screen view.
MyDetailViewController *myDetailViewController = [[MyDetailViewController alloc] initWithNibName:#"MyDetailViewController" bundle:nil];
[myDetailViewController.view setFrame:CGRectMake(0, 0, 1024, 768)]; //might not need this
[self presentViewController:newDetailViewController animated:YES completion:^{
NSLog(#"complete"); //optional
} ];
To dismiss or hide this MyDetailViewController with a tap or touch, you can use UITapGestureRecognizer or touchesEnded method and using one of the dismiss methods (refer back to Apple's UIViewController again for this).
Q2: I personally have not used UIWebView to display PDF and not sure if iBooks is using UIWebview to do it. But to display a varieties of popular documents formats, you can use either the QLPreviewController class or UIDocumentInteractionController. You can hide the toolbar while the document is displayed.
Good luck.
I need to modify a view's modal presentation with this parameters:
1 - Modal view only fills the ipad's right half of the screen.
2 - The animation runs from the left half of the screen.
I have search in iosframeworks.com, cocoacontrols.com, the books from big nerd rach, ios recipes, ios pushing the limits, stackoverflow and google. Is some posibility to do that?
Thanks for your assistance
For testing, after two days of searching answers, I create the following code, I'm executing the following code since the root view controller CMMainView, the viewcontroller CMVistaModal is empty, its doesn't have any overrided method nor xib nor another variable, the device family is iPad
-(IBAction)accion:(id)sender
{
CMVistaModal *modal = [[CMVistaModal alloc] init];
[modal setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController:modal animated:NO completion:nil];
[modal.view.superview setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[modal.view.superview setFrame:CGRectMake(800, 120, 200, 500)];
[UIView animateWithDuration:1 animations:^{
modal.view.superview.transform = CGAffineTransformMakeTranslation(-200, 0);
}];
}
how can i perform the same operation but overriding the methods from CMVistaModal?
Absolutely. Just make a new view and add it to your existing view and animate it into position. You can have another view appear behind it blocking any touches to other views.
Anything is possible. It just depends on how much work you wish to put in.
So a standard UIModalPresentationFormSheet or UIModalPresentationPageSheet comes for free. But what you want isn't standard so you have to bake your own.
What I would do here is create a "fake" modal.
With
XYViewController -> Container View
Container View -> Semi Opaque blocker
-> Half Screen Content
The blocker covers the entire screen and goes in immediately and prevents interaction with the rest of the UI
Then animate the "Half Screen Content" in from the left with a standard frame animate. How you choose to dismiss this fake modal is up to you but if it comes in from left perhaps it should depart to the left.
I am trying to write an app that displays a simple logo/splash page while the app retrieves some data. I cannot seem to find a tutorial anywhere.
I have a "MainWindow.xib" file that will have my splash page, and I'm setting that as my "Main Interface" in my Info.plist, however, I cannot seem to see how to replace that page with a .xib that contains a UINavigationController. I thought I would just create a new UIController, that had a UINavigationController and in my .xib I'll drag in a Navigation Controller and set all my information, but it's giving me real fits.
So, I figured I would have a UIController that I would "alloc" and "init" with my second .xib that contains all my navigation.
myMainController = [[UIController alloc] initWithNibName:#"MainNavController":nil];
in "MainNavController.xib", I've dragged in a Navigation Controller, but I don't know what to connect it to????
I'm sure I'm going down the wrong, path; but I cannot find a decent tutorial for this.
Can someone give direction or link to a decent tutorial?
Thanks.
Are you ever actually adding the new controller to your existing view? If not, something like:
[self.view addSubview:myMainController.view];
should do it for you. A better alternative is likely to be:
self.window.rootViewController = myMainController;
But I'm fairly new to this and maybe I've missed something ...
To display a splash screen while the app is loading you can use Default.png image file.
However, I think your question is how to display another splash screen for a period of time after the app has been loaded.
In you MainWindow.xib keep your window separated from your Navigation Controller. Add your splash screen view with an image to the xib.
Make two outlets: one for slash view, one for Navigation Controller.
IBOutlet UIView* _spashScreenView;
IBOutlet UINavigationController* _navigationController;
In applicationDidFinishLaunching method add your splash screen view to the window.
[_window addSubview:_spashScreenView];
// lay it out
When you are ready to display your navigation controller:
[_spashScreenView removeFromSuperView];
[_window addSubview:_navigationController];
I'm using UIModalTransitionStylePartialCurl to show a modal view in iPad.
modalViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[[self parentViewController] presentModalViewController:modalViewController animated:YES];
self is the right side view controller of my SplitViewController.
When I do this, the page is curled all the way to the top even though the size of the view of modalViewController is small. I only need it to curl a little so it would reveal ONLY the area taken by modalViewController. What I'm trying to do is something exactly like the iPad maps application settings.
I tried using all the modalPresentationStyle options for the modal view and I also tried setting the modalPresentationStyle.view.frame to a small CGRect but still couldn't get it to work.
Can anybody help on this...thanks in advance..
Just leave a clean space (No Controls or Images) in the top of your PresentedViewController, the Framework make the rest.
I have yet to find a more optimal solution, but I've been able to get good results by making the modal (revealed) view the same size as the parent (curling) view. iOS looks at the subviews to determine where to stop the curling and shows "just enough" of the subview to keep the subview pieces on-screen.