i am adding a label to camera overlay and i successfully added it
but what i am facing is the label is also appearing in preview of the taken picture
i want to display the label in camera overlay not in preview of the taken picture for adding label i am using the following code
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
overlayView.opaque = NO;
overlayView.backgroundColor = [UIColor clearColor];
[overlayView addSubview:topImgView];
[overlayView addSubview:btnInfo];
[overlayView bringSubviewToFront:btnInfo];
UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(20, 0,290,150)];
label.text =#"Hold the bottle steady, left align the prescription label, and then take the photo";
label.backgroundColor = [UIColor clearColor];
label.numberOfLines = 2;
label.textAlignment = UITextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:14.0];
label.textColor = [UIColor whiteColor];
[overlayView addSubview:label];
_infoLabel =label;
[label release];
//Image picker
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.cameraOverlayView=overlayView;
[self presentModalViewController:imagePicker animated:YES];
_imagePicker =imagePicker;
[imagePicker release];
[topImgView release];
[overlayView release];
can any one please help me how to do that thing...
You need to crop the image based on your overlay dimensions. You could try this tutorial which provides a good explanation.
Beginning iOS4.0, the images captured from camera are saved along with their exif data and rotation information. So, you cannot crop them in the standard way as you would with the UIImages The link above deals specifically with images captured from camera.
Related
I search for a lot forums but nothing found, my problem is that
I need preload some data from the web to load to the UITableView.
I saw some apps solved this problem, when show UITableView they shows "waiting circle" as modal view and after data is loaded just hide this circle.
Is there simple solution to do this?
What I need to do?
What kind of Request do I need: synchronius or asynchronius?
How to show this circle, do I need to show animatedGif or there is some internal/external control for this?
You need to make a NSThread for your "waiting circle"-(Activity Indicator).
1)Threads How do I create an NSThread that isn't the main thread.
2)Activity Indicator How to use activity indicator view.
- (void)showWaitingView {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CGRect frame = CGRectMake(90, 190, 32, 32);
UIActivityIndicatorView* progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame];
[progressInd startAnimating];
progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
frame = CGRectMake(130, 193, 140, 30);
UILabel *waitingLable = [[UILabel alloc] initWithFrame:frame];
waitingLable.text = #"Processing...";
waitingLable.textColor = [UIColor whiteColor];
waitingLable.font = [UIFont systemFontOfSize:20];;
waitingLable.backgroundColor = [UIColor clearColor];
frame = [[UIScreen mainScreen] applicationFrame];
UIView *theView = [[UIView alloc] initWithFrame:frame];
theView.backgroundColor = [UIColor blackColor];
theView.alpha = 0.7;
theView.tag = 999;
[theView addSubview:progressInd];
[theView addSubview:waitingLable];
[progressInd release];
[waitingLable release];
[window addSubview:[theView autorelease]];
[window bringSubviewToFront:theView];
[pool drain];
}
- (void)removeWaitingView {
UIView *v = [window viewWithTag:999];
if(v) [v removeFromSuperview];
}
I have made an iPad application, in that I used navigation control,
now in the title bar , I want to put image on left side, so I hide title bar with label, but label is not covering entire width of title bar,
IL APP IN THE SCREEN SHOT,
here is the code snippet,
UILabel *titleView = (UILabel *)self.navigationItem.titleView;
if (!titleView) {
titleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 800, 50)];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20.0];
titleView.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
titleView.textColor = [UIColor yellowColor]; // Change to desired color
titleView.backgroundColor=[UIColor blackColor];
titleView.text = #"IL APP";
titleView.textAlignment=UITextAlignmentCenter;
//self.navigationItem.titleView = titleView;
[self.navigationItem setTitleView:titleView];
[titleView release];
}
#Gama as far as your question is concerned you are asking to put an Image but your real issue being described is that the label is not covering up the title bar. To cover that properly you can use
UILabel *titleView = (UILabel *)self.navigationItem.titleView;
if (!titleView) {
titleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 32)];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20.0];
titleView.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
titleView.textColor = [UIColor yellowColor]; // Change to desired color
//titleView.backgroundColor=[UIColor blackColor];
titleView.text = #"IL APP";
titleView.textAlignment=UITextAlignmentCenter;
[self.navigationItem setTitleView:titleView];
[titleView release];
}
[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
For using an image you can use an image view instead of a label to be assigned as the titleView for navigationItem.
Hope it helps
I tried to solved your problem but I get the same result.
But you can hide navigation bar and add the UILabel in to your ViewController
self.navigationController.navigationBarHidden = FALSE;
[self.view addSubview:titleview];
UIImageView *imageNav = [[UIImageView alloc] initWithImage: [UIImage imageNamed: #"navImage.png"]];
[self.navigationController.navigationBar addSubview:imagenav];
[self.navigationController.navigationBar sendSubviewToBack:imageNav];
[imageNav release];
Hi i wanted to do the same thing and i saw your posting, i basically used some of the code you provided and modified it a little and got it to work see below:
//declare and initialize your imageView
UIImageView *titleImage = (UIImageView *)self.navigationItem.titleView;
titleImage = [[UIImageView alloc]
initWithFrame:CGRectMake((self.navigationController.navigationBar.frame.size.width/2)
- (100/2), 0, 100, self.navigationController.navigationBar.frame.size.height)];
//setting the image for UIImageView
titleImage.image = [UIImage imageName:#"photo.jpg"];
//NOTE: you have to do this line at the bottom to add image to the navigation bar Try it it WORKS!
self.navigationItem.titleView = titleImage;
In the picture below, what type of view is used to create the 'turning on reminders' activity indicator? Is it a custom view with a label and a standard UIActivityIndicator? a built in UIKit class?
As others have said, it is a custom view. Fortunately, a kind third party has created a nice open source implementation:
https://github.com/jdg/MBProgressHUD
yes it is view with a label and a standard UIActivityIndicator.
You don't need a custom view. Something like this completely untested code would do it:
- (UIView *)busyOverlayViewWithText:(NSString *)text {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(80, 120, 160, 160)];
view.opaque = NO;
view.clipsToBounds = YES;
view.backgroundColor = [UIColor colorWithWhite:0 alpha:.2];
view.layer.cornerRadius = 8;
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(80, 30);
[spinner startAnimating];
[view addSubview:spinner];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 60, 160, 100)];
label.text = text;
label.textColor = UIColor.whiteColor;
label.backgroundColor = UIColor.clearColor;
label.textAlignment = UITextAlignmentCenter;
label.numberOfLines = 0;
label.lineBreakMode = UILineBreakModeWordWrap;
[view addSubview:label];
return view;
}
this is using ARC. Add (auto)releases if you use manual memory management.
This is not a single built-in class. Rather it is a composition of:
A custom transparent view, possibly an image.
A standard activity indicator.
A standard label.
If you want to create something similar then you can easily put them all in a single class.
I currently have a UITextView which is contained in a UIViewController using the following code:
UIViewController *container = [[UIViewController alloc] init];
container.view.frame = CGRectMake(0, 0,
[UIScreen mainScreen].bounds.size.width, 1000);
//[UIScreen mainScreen].bounds.size.height
container.view.userInteractionEnabled = YES;
container.view.clipsToBounds = YES;
UIImageView *imgView = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:#"myImage.png"]];
imgView.frame = container.view.frame;
imgView.userInteractionEnabled = YES;
[container.view addSubview:imgView];
[imgView release];
UITextView *textContained = [[UITextView alloc]
initWithFrame:CGRectMake(0, 0, container.view.bounds.size.width, 1000)];
//container.view.bounds.size.height
textContained.font = [UIFont fontWithName:#"Calibri" size:14];
textContained.scrollEnabled = YES;
textContained.editable = NO;
textContained.textColor = [UIColor whiteColor];
textContained.backgroundColor = [UIColor clearColor];
textContained.font = [UIFont boldSystemFontOfSize:14];
textContained.userInteractionEnabled = YES;
textContained.alwaysBounceVertical = YES;
textContained.contentSize = CGSizeMake(container.view.frame.size.width,
container.view.frame.size.height);
I then set my UItextView text property with some text, which extends past the current screen size. I then add my UITextView to my container using the following code.
switch (indexPath.row) {
case 0:
textContained.text = #"LOTS AND LOTS OF TEXT";
[container.view addSubview:textContained];
[self.navigationController pushViewController:container animated:YES];
[textContained release];
break;
default:
break;
}
[container release];
When I test this code, the text appears just fine in the UITextView and everything looks ok. But the problem is when I try to scroll down to see the remainder of the text. Everytime I scroll down the UITextView scrolls back in to its original position. I have tried several ways to get this to work, but I think I need some fresh eyes to see what I'm doing wrong.
Any help is greatly appreciated.
First, you don't want to set the contentSize of a UITextView, since it is determined by the length of text automatically.
Try to make the height of textView smaller. For example:
UITextView *textContained = [[UITextView alloc]
initWithFrame:CGRectMake(0, 0, container.view.bounds.size.width, 50)];
And give it more text, like:
textContained.text = #"LOTS AND LOTS OF TEXT\nLOTS AND LOTS OF TEXT\nLOTS AND LOTS OF TEXT\n\nLOTS AND LOTS OF TEXT\nLOTS AND LOTS OF TEXT\n";
Im trying to make my own calendar similar to iCal and all is going well except for one thing. I plan to have the calendar selection up the top then a table list down the bottom. I can do this but then the calendar is in the same subview as the table and scrolls with it. Although I am currently not using a nib if I build it in a nib then the table wont resize to take up whatever the calendar doesn't. ie it should be larger in say February where as December will be small (exactly like the apple iCal version) I have seen other apps do this. Any ideas on how I would go about this?
Add the tableview and the calendar view separately to the main view.
Example:
- (void)loadView {
[super loadView];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
topView.backgroundColor = [UIColor darkGrayColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 280, 60)];
label.text = #"Stationary top view";
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
[topView addSubview:label];
[label release];
[self.view addSubview:topView];
[topView release];
UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 100, 320, 380) style:UITableViewStyleGrouped];
tableview.delegate = self;
tableview.dataSource = self;
[self.view addSubview:tableview];
[tableview release];
}
Screenshot:
alt text http://static.benford.name/tableview_with_topview.png