Phonegap-Plugin ExternalFileUtil doesn't work on all devices - ios

I'm using the ExternalFileUtil-Plugin from Phonegap (https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ExternalFileUtil). But it work's only at iPhone. It work's on iPhone-simulator with iOS 6.0 and 6.1 and work's on iPhone 4 and 5 with iOS 6.x. But it doesn't work on iPad, neither on simulator nore on devices and on iPod Touch with iOS 5.1 it doesn't work too ;(
I've tried any suggestions described in the comments on http://www.tricedesigns.com/2012/08/15/open-with-in-ios-phonegap-apps/ but nothing helps me.
In my opinion the following lines must be adjusted:
UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
controller.delegate = self;
controller.UTI = uti;
[controller retain];
CDVViewController* cont = (CDVViewController*)[ super viewController ];
CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
[controller presentOptionsMenuFromRect:rect inView:cont.view animated:YES];
Have somebody any suggestions?

My current solution for this issue: Replace
CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
with this
CGRect rect = CGRectMake(0, 0, 1500.0f, 50.0f);
and it works like a charm. Thanks to Mahendra Liya (see comment on tricedesigns.com).

Related

popover full screen in iOS 8

I have the following code for a UIPopoverController. It is working fine in iOS 7. However, in iOS 8, the popover becomes full-screen which I do not want. How do I keep the popover from filling the entire screen in iOS8?
CGRect buttonFrame = [[[[[self tabBarController] tabBar] subviews] objectAtIndex:index+1] frame];
popover = [[UIPopoverController alloc]initWithContentViewController:viewmapmenu] ;
popover.popoverContentSize = CGSizeMake(95, 128.0) ;
popover.delegate = self ;
[popover presentPopoverFromRect:buttonFrame inView:self.tabBarController.tabBar permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES] ;
Try to add this delegate method.
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller;{
return UIModalPresentationNone;
}
See, here is the situation. if you are presenting the popover in iPhone then it will not work in iOS 8 as Apple has completely restricted it even if it was previously working. Now you cannot present popover in iPhone as all the access to the private methods of UIPopover is blocked.
You can look into the FPopover Library in github to use popover in iPhone:-
https://github.com/50pixels/FPPopover

How to create a portrait iAd banner view for iPhone/iPad

In Apple iAd programming guide, in the apple developer library with a date of 9/17/14, I'm looking to make that when user clicks on iAd banner and game is in Portrait mode, that the banner shows in portrait mode and not landscape like i'm currently getting. The following is the code I found in the 9/17/14 version of iAd programming guidelines.
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:adView];
Problem is Xcode 6.1 tells me ADBannerContentSizeIdentifierPortrait has been deprecated after iOS 6.0. Don't know why a deprecated code was inside a 9/17/14 made guideline. So what is the non-depracated code to make the iPad/iPhone load iAd in Portrait or UpsideDown mode?
First you could try self.canDisplayBannerAds = YES;
Second, you could make an ADBannerView and set the size due to the orientation.
ADBannerView *banner = [[ADBannerView alloc] init];
if([UIScreen mainScreen].bounds.size.width < [UIScreen mainScreen].bounds.size.height){
banner.frame = CGRectMake(0, 0, 120, 640);
[self.view addSubview:banner];
}

UIPopoverController Width Not Setting

My popovers are sizing incorrectly in iOS 7. The height is working fine, but the width is not getting set at all. The popover has a very skinny width, no matter what I set it to. It still works in iOS 6 but breaks in iOS 7. Is there something new I need to do with popovers in 7 that I'm missing?
Here's the code that works in iOS 6 and not iOS 7:
self.mediaPicker = [[UIImagePickerController alloc] init];
self.mediaPicker.contentSizeForViewInPopover = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
self.cameraPickerPopover = [[UIPopoverController alloc] initWithContentViewController:self.mediaPicker];
self.cameraPickerPopover.popoverContentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
self.cameraPickerPopover.delegate = self;
[self.cameraPickerPopover presentPopoverFromRect:self.toolbar.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:animated];
I found out contentSizeForeViewInPopover is deprecated in iOS 7 so I updated the code as follows and it's still not working:
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
self.mediaPicker.contentSizeForViewInPopover = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
} else {
self.mediaPicker.preferredContentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
}
The answer provided here
How to change the size width of UIImagePickerController on iPad?
is correct, except that for iOS 7, the contentSizeForViewInPopover property should be replaced by the preferredContentSize property.
The UIImagePickerController's delegate implements the UIImagePickerControllerDelegate and the UINavigationControllerDelegate protocols.
Adding the following method in the delegate implementation solves the issue in iOS 7 for me :
- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated
{
if (SYSTEM_VERSION_GREATER_THAN(#"7.0"))
viewController.preferredContentSize = CGSizeMake(800,800);
else
viewController.contentSizeForViewInPopover = CGSizeMake(800, 800);
}

Image missing from distribution

I am having an issue where an image is missing, but only when built for distribution. Also, it only occurs on the iPhone 5, but not for the iPhone 4 or 4S.
This is a screenshot when built for development, on the simulator.
And this is a screenshot when built for distribution, on an actual iPhone 5.
I have a single target for both development and distribution. Relevant code:
int deviceNumber = 4;
if([UIScreen mainScreen].bounds.size.height > 500)
deviceNumber = 5;
MYIntroductionView *introductionView = [[MYIntroductionView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height) panels:#[panel1,panel2,panel3]];
if(deviceNumber == 4){
[introductionView setBackgroundImage:[UIImage imageNamed:#"One Degree_Iphone4_Background.png"]];
}
else{
[introductionView setBackgroundImage:[UIImage imageNamed:#"One Degree_Iphone5_Background.png"]];
}
And within MyIntroductionView.m, the relevant code is:
-(void)setBackgroundImage:(UIImage *)backgroundImage{
self.BackgroundImageView.image = backgroundImage;
}
-(void)buildBackgroundImage{
self.BackgroundImageView = [[UIImageView alloc] initWithFrame:self.frame];
self.BackgroundImageView.backgroundColor = [UIColor clearColor];
self.BackgroundImageView.contentMode = UIViewContentModeScaleToFill;
self.BackgroundImageView.autoresizesSubviews = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self addSubview:self.BackgroundImageView];
}
buildBackgroundImage is called within the init function.
I'm not 100% sure this is still the case but I know it used to be:
The iOS Simulator is not case-sensitive with regard to external filenames (such as your images). So if the image is named "myImage.png" and your program asks for "MyImage.png", the simulator will correctly find and load the image.
However when you try and run it on the device, it is case sensitive, and will not accept the incorrectly-cased file.
So double check that your capitalization of the file itself is identical to what you're asking for in your program. Hopefully that will fix your issue right up.

GKAchievementViewController full screen (or PageSheet) odd display

I am working with the iPad at the moment and am using Cocos2D. Up until now I have just been testing with the default view when dealing with Game Center. I am attempting to now set it up as I want it, which is using either full screen or PageSheet (which is shown in the image).
My question(s) is fairly simple (at least in the asking). Why exactly is it doing that? I can not figure out how to access that "wooden" frame that is drawing over top of achievement view.
Here is the code I have been using (including random stuff I have been trying) to get to a bigger view.
- (void)showAchievements:(id)sender
{
GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
if (achievements != nil)
{
achievements.achievementDelegate = self;
tempVC = [[UIViewController alloc] init];
// tempVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
// tempVC.interfaceOrientation = [[UIDevice currentDevice] orientation];
[achievements shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft];
[achievements shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
[tempVC shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft];
[tempVC shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
// achievements.navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
// tempVC.wantsFullScreenLayout = YES;
tempVC.modalPresentationStyle = UIModalPresentationPageSheet;
tempVC.view.superview.bounds = CGRectMake(0, 0, winSize.width, winSize.height);
// tempVC.view.superview
// tempVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
// achievements.wantsFullScreenLayout = YES;
achievements.modalPresentationStyle = UIModalPresentationPageSheet;
// achievements.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
achievements.navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
// achievements. = CGRectMake(0, 0, winSize.width, winSize.height);
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
[tempVC presentModalViewController:achievements animated:YES];
}
}
My understanding of UIKit is extremely limited. I use Cocos2D and Box2D and pretty much nothing else (up until now anyway). Please, any help you can provide will be very much appreciated. If you could simply show me how this would be done properly (without all the junk code I have in there) that would be perfect.
Thank you :)
I just tried to do this with UIModalPresentationPageSheet and I see the same result, it's not just you. The "correct" way to do this is not to change the size of the modal view! :) Apple's UI designers have chosen their desired presentation style & size of the achievements view; it's best not to mess with that, for consistency between games.
There isn't much customization available with this, you will need to get the data and display it yourself if you want that.
If you size the view to 420x512, it will display correctly.
Try something like this:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// The device is an iPad running iPhone 3.2 or later.
leaderboardController.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90.0f));
leaderboardController.view.bounds = CGRectMake(0, 0, 420, 512);
//leaderboardController.view.center = CGPointMake(240, 160);
leaderboardController.view.center = CGPointMake(364, 512);

Resources