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
Related
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! ;)
I am using Flurry in my iOS app, to display banner ads as follows:
self.flurryBanner = [[FlurryAdBanner alloc] initWithSpace:#"FlurryBanner"];
self.flurryBanner.adDelegate = self;
[self.flurryBanner fetchAdForFrame:self.view.frame];
while I can find documentation in AdMob to hide banner (setHidden = YES), I could not find any information on how to do so. Any ideas for a good practice?
You can do it like this
UIView *flurryContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 150, self.view.frame.size.width, 50)];
[self.view addSubview:flurryContainer];
[self.flurryBanner displayAdInView:flurryContainer viewControllerForPresentation:self];
And then flurryContainer.hidden = YES;
I'm running into a problem trying to perform a certain effect on iOS with tableviews...I know this can be done with normal UIViewControllers, but can't seem to pull it off with UITableViewControllers.
The effect is showing a clear background image behind a tableview and and as the user scrolls down the tableview, the background blurs. No problem getting that to happen.
The issue I'm having is that using a UITableViewController, I can only seem to have 1 ImageView behind the TableView and to create the blurring effect, the extension i am using will require 2 image views, one of which is the blurred image and has it's opacity set to 0 at launch.
This is code I know works using a UIViewController:
UIImage *background = [UIImage imageNamed:#"bg_004.png"];
self.backgroundImageView = [[UIImageView alloc] initWithImage:background];
self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.view addSubview:self.backgroundImageView];
self.blurredImageView = [[UIImageView alloc] init];
self.blurredImageView.contentMode = UIViewContentModeScaleAspectFill;
self.blurredImageView.alpha = 0;
[self.blurredImageView setImageToBlur:background blurRadius:10 completionBlock:nil];
[self.view addSubview:self.blurredImageView];
This is the code I am trying on the UITableViewController that does not work:
UIImage *background = [UIImage imageNamed:#"bg_004.png"];
self.backgroundImageView = [[UIImageView alloc] initWithImage:background];
self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.tableView setBackgroundView:self.backgroundImageView];
// Also tried this, to no success
[self.tableView.backgroundView addSubview:self.blurredBackgroundView];
self.blurredBackgroundView = [[UIImageView alloc] init];
self.blurredBackgroundView.contentMode = UIViewContentModeScaleAspectFill;
self.blurredBackgroundView.alpha = 0;
[self.blurredBackgroundView setImageToBlur:background blurRadius:10 completionBlock:nil];
[self.tableView setBackgroundView:self.blurredBackgroundView];
// Also tried this, to no success
[self.tableView.backgroundView addSubview:self.blurredBackgroundView];
If anyone has some suggestions how how to make this work, i'd love some advice. I really wouldn't like to change my code from a TableViewController to a UIViewController
Set the table view's backgroundView property to point to an instance of UIView, and then add your image views as subviews of the new view. You can't directly add subviews to instances of UIImageView
Just like Häagen-Dazs' App, I think it just add an animation before the photo iPhone is taking. I have checked UIImagePickerController and it didn't say how to add another picture or animation before the image. I just want to add some interesting things in front of the scene that I'm taking. Could anyone provide any tutorial? Thanks.
add you custom UIView with animation like this into ImagePickerView
_imagePickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePickerCamera.delegate = self;
_imagePickerCamera.showsCameraControls = NO;
_imagePickerCamera.navigationBarHidden = YES;
_imagePickerCamera.toolbarHidden = YES;
_imagePickerCamera.wantsFullScreenLayout = YES;
//create an overlay view instance
OverlayView *overlay = [[OverlayView alloc]
initWithFrame:self.view.bounds];
//set our custom overlay view
_imagePickerCamera.cameraOverlayView = overlay;
overlay.captureButton.frame = CGRectMake(self.view.frame.size.width/2 - 30, self.view.frame.size.height - 60, 60, 60);
[overlay.captureButton addTarget:self action:#selector(captureImageWithButton:) forControlEvents:UIControlEventTouchUpInside];
[self performSelector:#selector(presentCameraView) withObject:nil afterDelay:0.0f];
You can add any overlay view you want using the cameraOverlayView property of the UIImagePickerController class.
Disclaimer: I'm something of an iOS n00b. I have a navigation-based app -- i.e., in my AppDelegate, I create the nav frame:
self.navigation_controller = [[UINavigationController alloc] initWithRootViewController:home_view_controller];
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
self.window.rootViewController = navigation_controller;
self.window.makeKeyAndVisible;
Inside the frame of my home view, I want a search bar, then the scrollable table view. So, I wrote this:
- viewDidLoad{
(HomeView*)home_view = [[HomeView alloc] init];
self.view = home_view
self.view.backgroundColor = [UIColor whiteColor]
(UITableView*)self.table_view = [UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.table_view.bounds.origin.y += 44;
self.table_view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.table_view.dataSource = self;
self.table_view.delegate = self;
[self.view addSubview:self.table_view];
search_frame = self.view.bounds;
search_frame.origin.y = 48.0;
search_frame.size.height = 48.0;
self.search_bar = [[UISearchBar alloc] initWithFrame:search_frame)];
[self.view addSubview:self.search_bar];
}
The table view displays fine, but occupies all the space below the navigation bar. I want to have the navigation bar, then immediately below it the search bar, followed by the table view. At the point of viewDidLoad, the UITableView does not yet have a non-zero bounding rect and I expect that's part of the problem. Additionally, I've specified UIViewAutoresizingFlexibleHeight in my autoresizingMask when I really want it glued against the search bar -- again, I believe this may be part of the problem.
What have I misunderstood here?
Thanks
Steve,
Try following changes:
1) Set tableview's frame using:
CGRect targetRect = CGRectMake(0, 48, self.view.frame.size.width, self.view.frame.size.heigth);
(UITableView*)self.table_view = [UITableView alloc] initWithFrame:targetRect style:UITableViewStylePlain];
2) Add following autosize mask also:
// This value will anchor your table view with top margin
UIViewAutoresizingFlexibleBottomMargin
3) Set searchbar's frame to following rect frame:
CGRecttMake(0, 0, self.view.frame.size.width, 48);
What I would do, is just add the UISearchBar as the first UITableView header.
(method: tableView:viewForHeaderInSection:)
Check this blog post:
http://jainmarket.blogspot.com/2009/08/add-searchbar-as-uitableviews-header.html