CustomIOS7AlertView landscape mode - ios

I'm trying to create a CustomAlertview using CustomIOS7AlertView, with text and image. Because I read that with simple AlertView is not possible to set a maximun height when we add an image...
My problem is this: I created the CustomAlertView with the image, but I can not in any way, that for the IPAD (in landscape) it is shown in landscape mode. It is always displayed as vertical.
I've tried rotating the customAlertview, but I have not succeeded ...
Could anyone help me?
This is my code:
UIView * vista = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
UIImageView *imgView;
if (([[UIDevice currentDevice].model rangeOfString:#"iPad"].location!=NSNotFound)) {
imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)];
} else {
imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
}
[imgView setImage:img];
[vista addSubview:imgView];
CustomIOS7AlertView *alertView = [[CustomIOS7AlertView alloc] init];
[alertView setContainerView:vista];
[alertView show];
Thank you!!!

Put observers for orientation change in CustomIOS7AlertView and then make the view correctly oriented every time orientation is changed.
Refer to : Detecting iOS UIDevice orientation to understand more on orientation change notifications.

Solved! As the colleague noir_eagle said, the problem was in the show (CustomIOS7AlertView.m) method, in particular had to modify the following line, which affects the rotation:
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
switch (interfaceOrientation) {
case UIInterfaceOrientationLandscapeLeft:
**self.transform = CGAffineTransformMakeRotation(M_PI * 360 / 180.0);**
Thank you ver much! ;)

Related

Why my iAds ads corrupted on iPads

On iPhone all ok. On iPads iAds ads looks like corrupted. But when it loads new ads (blue, red etc..) all looks great. Where is my mistake?
// in applicationDidFinishLaunchingWithOptions
CGSize winSize = [[CCDirector sharedDirector] viewSize];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
adsBanner = [[ADBannerView alloc] initWithFrame:CGRectMake(0, winSize.height - 66, 768, 66)];
}
else
{
adsBanner = [[ADBannerView alloc] initWithFrame:CGRectMake(0, winSize.height - 50, 320, 50)];
}
// somewhere in AppDelegate
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
[self.window.rootViewController.view addSubview:banner];
}
Here is image from iPad with corrupted ads:
Your question has nothing to do with iPad. Why are you initializing the ADBannerView like this? You are not using the API correctly. Use the designated initializer method initWithAdType: to get the correct result (you most likely need to use ADAdTypeBanner as the type).
To resize to fit to a specific view, you need to use what is recommended here.

UIImagePickerViewController of custom frame size

On my app, I am trying to initialise and present a UIImagePickerViewController instance of custom size. Basically, I want a square view of size 200x200 to hover over my viewController. I tried out the following code and it still presents the camera overlay in full-screen mode. Any suggestions on how I can achieve a custom frame on my overlay view?
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = self; imagePickerController.showsCameraControls = NO;
imagePickerController.cameraOverlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[self presentViewController:imagePickerController animated:NO completion:nil];
Any help is appreciated.
You need use cameraOverlayView property. Set to this property your custom view that contains transparent square of size 200x200.
Notice to code that you've provided:
When you create view [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; it uses clear (transparent) colour by default. That's why you don't see it after launching.
Change it's background colour and it will become visible over the camera layer:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
view.backgroundColor = [UIColor redColor];
imagePickerController.cameraOverlayView = view;
You need to look at Face Detection enabling for ios and its API in Apple developer library.
CoreImageFramework provides the API where on detection you can hover .
CIImageFilter, CIFilter methods are used
for Reference please read Apple Documentation and Check the following sample
Square Cam
Using UIImagePIckerController Its Difficult to overlay and Hover on move , Use AVFoundation framework for better Results

How to center AdMob advertisement on iPad?

I'm just testing out the AdMob code I've put into my application and I can't figure out why the advertisement is not centring on the iPad. On the iPhone it perfectly centres itself.
This is the code:
//google ad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
googleBanner_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard origin:CGPointMake(0, 0)];
}else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
googleBanner_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:CGPointMake(0, 0)];
}
//googleBanner_.adUnitID = #"pub";
googleBanner_.rootViewController = self;
[self.view addSubview:googleBanner_];
[googleBanner_ loadRequest:[GADRequest request]];
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
I had assumed that I could change the x-coordinate on the iPad ad position but that simply put half of it off the screen.
(this is what I did)
googleBanner_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard origin:CGPointMake(384, 0)]; //768/2 = 384
Any ideas as to why this is happening? What can I do to properly center the advertisement on the iPad? NOTE: kGADAdSizeLeaderboard dimensions = 728 x 90
Fixed it. For those that encounter the same problem, simply take the x-dimension of the kGADAdSizeLeaderboard which is 728, and subtract it from the total width which is 768, which gives you 40. Then divide 40 by two to have it even on both sides, giving you 20. Then simply set the x-coordinate in the origin to 20, placing the ad in the middle of the screen.
Code:
googleBanner_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard origin:CGPointMake(20, 0)];

JASidePanels, device is in landscape but the panel are still in portrait

I'm using the JASidePanels. I have set my project and storyboard to show in landscape orientation only. The result shown as below. It seems like the view are read as portrait by JASidePanels. However when i turn the device into to the other side, the panel orientation will be corrected. Please advise how to fix this issue.
Thanks.
You can add the following line in viewDidAppear() :
[self _layoutSideContainers:YES duration:0];
Try replacing the -(void)_layoutSidePanels method with this:
- (void)_layoutSidePanels {
if (self.rightPanel.isViewLoaded) {
....
}
if (self.leftPanel.isViewLoaded) {
CGRect frame = self.leftPanelContainer.bounds;
frame.size.width = floorf(self.view.bounds.size.width * self.rightGapPercentage);
if (self.shouldResizeLeftPanel) {
frame.size.width = floorf(self.view.bounds.size.width * self.rightGapPercentage);
}
self.leftPanel.view.frame = CGRectMake(0, 0, self.view.bounds.size.width * self.rightGapPercentage, self.view.bounds.size.height);
}
}
Please give me a feedback, I'm not sure if this is the problem
I think i found the solution. I replace the following code in viewDidLoad() to viewDidAppear(). The problem is after the view did appear, then it will get the correct view width.
self.centerPanelContainer = [[UIView alloc] initWithFrame:self.view.bounds];
_centerPanelRestingFrame = self.centerPanelContainer.frame;
_centerPanelHidden = NO;
self.leftPanelContainer = [[UIView alloc] initWithFrame:self.view.bounds];
NSLog(#"%f",self.leftPanelContainer.frame.size.width);
self.leftPanelContainer.hidden = YES;
self.rightPanelContainer = [[UIView alloc] initWithFrame:self.view.bounds];
self.rightPanelContainer.hidden = YES;
[self _configureContainers];
[self.view addSubview:self.centerPanelContainer];
[self.view addSubview:self.leftPanelContainer];
[self.view addSubview:self.rightPanelContainer];
self.state = JASidePanelCenterVisible;
[self _swapCenter:nil previousState:0 with:_centerPanel];
[self.view bringSubviewToFront:self.centerPanelContainer];

Can't make modal view appear right in the center of the screen on iPad iOS6

I have a problem with modalviewcontrollers that I want to represent on iPad screen. If I leave the size as it is, then it's all centred fine. But I have very few info on these views, so I need to resize them.
So, when I resize them, I can't force them to appear in the middle of the screen. Even if I manage to center one of them in one orientation, it's messed up in other one.
Here is my current code:
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:acvc];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[nav setModalTransitionStyle: UIModalTransitionStyleCoverVertical];
[[acvc view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"main_bg.jpg"]]];
[self presentViewController:nav animated:YES completion:nil];
nav.view.superview.frame = CGRectMake(self.view.bounds.size.width/2 + 175, self.view.bounds.size.height/2 - 125, 350, 250);
// nav.view.superview.center = self.view.window.center;
Would appreciate any help, thank you.
Here's a method that works on iOS7 as well as iOS6 and iOS5 and still allows you to use UIModalTransitionStyleCoverVertical:
-(void)presentController:(UIViewController*)controller fromRootController:(UIViewController*)rootController withSize:(CGSize)size
{
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:controller];
nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[rootController presentModalViewController:nav animated:YES];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
nav.view.superview.backgroundColor = [UIColor clearColor];
nav.view.bounds = CGRectMake(0, 0, size.width, size.height);
}
else
{
nav.view.superview.bounds = CGRectMake(0, 0, size.width, size.height);
}
}
Change your last line to the following:
nav.view.superview.bounds = CGRectMake(0, 0, 350, 250);
Stopped working in iOS7, unfortunately.
Only changing ModalTransitionStyle to Dissolve solves the problem. Maybe it's a bug in iOS 7...
in ios 7 you can use :
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.view.superview.bounds = CGRectMake(0, 0, width, height);
}
it works.

Resources