Add UITextField to cameraOverlay - iphone

Hi all I am trying to add a UITextField to my cameraOverlay. I am getting it to show up on my camera view, but it is not editable. Its not responding at all. What approach do I need to take to get it to repsond?
I have looked at this questions, but do not understand how to set a transparent View Controller on top of my cameraOverly.
Suggestion for camera overlay
Thanks in advance!

Steps should be:
Create your picker.
Create an empty view with clearColor background.
Add your textfield with addSubview: to the view in step 2.
Set cameraOverlayView to the view created in step 2.
Present your picker.
In code:
//self.picker and self.textField being your UIImagePickerController and UITextField instances.
emptyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //This frame will make it fullscreen...
emptyView.backgroundColor = [UIColor clearColor];
[emptyView setAlpha:1.0]; //I think it is not necessary, but it wont hurt to add this line.
self.textField.frame = CGRectMake(100, 100, self.textField.frame.size.width, self.textField.frame.size.height); //Here you can specify the position in this case 100x 100y of your textField preserving the width and height.
[emptyView addSubview:self.textField];
self.picker.cameraOverlayView = emptyView; //Which by the way is not empty any more..
[emptyView release];
[self presentModalViewController:self.picker animated:YES];
[self.picker release];
I typed the code here myself so it could have some typo, Hope it helps!

Related

how can i make uiview on the Uinavigationbar

I am doing one iphone app. In this app i want to disable the back navigationleftbarbutton. I have used this below code for disable the navigationleftbarbutton but it is not working. Now i have created one view and i have added in uinavigationbar. But now i want to make that view in transparent view. And also how can i remove my customview(myview1) from the navigationbar. I have attached my code. please some body help me to solve my issue.
Disable Code:
self.navigationItem.leftBarButtonItem setEnabled:NO];
And This is my customview Code:
myview1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
myview1.backgroundColor = [UIColor redColor];
button = [[UIBarButtonItem alloc]initWithCustomView:myview1];
self.navigationItem.leftBarButtonItem = button;
How can i make myview is transparent view. And how can i remove mycustomview(myview1) from navigationbar. Thanks in advance.
you can hide navigation back button by writing code below:
self.navigationItem.leftBarButtonItem.hidden = YES;
and your view ie myview can be transparent by changing alpha value of the view
[myview setAlpha:0.3]; //alpha value ranges from 0 to 1
By settign alpha value 0.0 makes view transparent and increases transparency as u increases alpha value

Setting modal image view?

In the Epic Win iPhone app, they seem to have some sort of image view in the front of another view. How does one implement this?
Example:
All you have to do is to create a new view and add it to the window. You can do that like this:
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
overlayView.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];
[overlayView addSubview:<#imageView#>];
[self.view.window addSubview:overlayView];
[overlayView release];
Let me know if that works for you.
From above example it seems that they just added Imageview on self.view and they decrease alpha of self.view. It doesn't seems something triky.
That's very simple and there are probably a few ways to do it.
The simplest is probably to just add an image view as subview of the window.
Check out this CustomAlert Class. Shows you how to change the background of a UIAlertView.

How to create a table in a view ( I dont want the table to cover up my entire screen)

Is there any way out .., that I can create a UITableView in a view such that it doesn cover up entire the screen...
For example :
I want the first half of the screen to be a UITextView and the next half portion of my screen to be
a UITableView..
Thanks in advance
CGRect cgRct = CGRectMake(0, 50, 320, 250);
UITableView *tableView1 = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStylePlain];
//tableView.editing = YES;
tableView1.dataSource = self;
tableView1.delegate = self;
tableView1.backgroundColor=[UIColor clearColor];
[self.view addSubview:tableView1];
You are probably creating a UITableViewController for your tableView and then realizing that you can't change the size of the tableView. Am I right? If that is the case then don't create a UITableViewController, just create a normal UIViewController and than add your tableView using Interface Builder or the code which other people posted here.
In Interface Builder (if you are using it), just drag-drop a UITableView to your UIView and adjust its width, height and y position in the Inspector.
If you are programmatically creating the view, change the frame of the UITableView
CGRect tablefrm = [tableViewObject frame];
tablefrm.origin.y = 240.0f //new origin
tablefrm.size.height = 240.0f; //new height
[tableViewObject setFrame:tablefrm]; //assuming already added the tableview to the view.

How to add Activity Indicator as subview to UIButton?

Can we add activity indicator as subview to UIButton?
If yes then plz tell me how to do that?
I used [button addSubview:activityIndicator];
Not working...
I found that adding a UIActivityIndicatorView to a UIButton was a really useful method to allow users to know something is happening without having to use the MBProgressHUD (I think the HUD is really good but should not be used in all situations.
For this reason I created two functions:
I have already allocated my UIButton so it is a class variable called _confirmChangesButton
I then create my activity indicator, set its frame (taking into account the button size) and then adding the indicator is easy.
- (void)addActivityIndicatorToConfirmButton {
// Indicator needs to be in the middle of the button. So half the screen less half the buttons left inset less half the activity indicator size
CGRect rect = CGRectMake([UIScreen mainScreen].bounds.size.width/2 - 10 - 15, 5, 30, 30);
UIActivityIndicatorView * activity = [[UIActivityIndicatorView alloc] initWithFrame:rect];
activity.hidesWhenStopped = YES;
[_confirmChangesButton setTitle:#"" forState:UIControlStateNormal];
[_confirmChangesButton addSubview:activity];
[activity startAnimating];
}
Having a removal function is also useful if you are using blocks. It might be that the completion task comes back with a failure and so we want to remove the indicator and change the title back. In this function we need to make sure to remove the indicator and not the button label which is the other subview on this button.
- (void)removeActivityIndicatorFromConfirmButton {
UIActivityIndicatorView * activity = _confirmChangesButton.subviews.lastObject;;
[activity removeFromSuperview];
[_confirmChangesButton setTitle:#"Confirm Change" forState:UIControlStateNormal];
}
I found that using these two you can create a much better user experience letting the user know what is going on when they press buttons.
Hope this helps
Use the below code below to add acitivity indicator a button or any uiview object
UIActivityIndicatorView *aView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
aView.frame = CGRectMake(0, 0, {yourButton}.frame.size.width, {yourButton}.frame.size.height);
aView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
[{yourButton} addSubview:aView];
[aView startAnimating];
Hope this will help..
I don't think it's possible to add a view to a button. UIButton have this method because it's inherited from UIVIew.
The real question is : why do you want to add an activity indicator on a button and not elsewhere ?
did you do [activityIndicator startAnimating]; ALso as u are using it in a tableview just check if the tags are set properly

iPhone - initWithFrame not working for UIActivityIndicatorView?

I am using a tableview with custom cells and want to change the content of the tableview on a button click. I am using an activity indicator while the cells are loading data.
This is how I am creating the indicatorview
indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(141.0, 190.0, 37.0, 37.0)];
indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
indicator.hidesWhenStopped = YES;
[[self tableView] addSubview:indicator];
But it appears as if the frame has no effect on the indicator. The indicator instead of displaying in the center of the table, appears in the navigation bar on the top left corner of the view.
I have no idea what is wrong with this and why this is happening. Can someone please help me out.
alt text http://www.freeimagehosting.net/uploads/95cbe49850.png
initWithFrame: is not the suggested method for creating a UIActivityInidcator. Taking a look at the API, you can see that to create a UIActivityIndicator, you should use
[[UIActivityIndicator alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
Then add it to your view and set its position with setCenter: as suggested by Pablo.
Also, adding it to a location in a table view will make it scroll with the table if the user scrolls up or down. If you put it in the table's superview instead, it will stay in place.
Try this:
activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
[activityIndicator setCenter:CGPointMake(160.0f, 208.0f)];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[activityIndicator startAnimating];
Calling to setCenter should give the behavior you are expecting.
Good luck!