I have UISearchBar on UITableView's header, I want to add UILabel above UISearchBar. UILabel is hidden for the first time, when User scroll down the TableView, UILabel will appear. It's done in WhatsApp, in the Contacts' tab.
What is the best way to do this?? Any help will be appreciated.
Regards
One way is to add the UILabel, UISearchBar and UITableView in a UIView.
Otherwise, add the UILabel in first row, search bar in the second row and go on...
Not able to test this right now but I think:
theHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - HEADER_HEIGHT, 320, HEADER_HEIGHT)]
headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, HEADER_HEIGHT)];
headerLabel.textAlignment = UITextAlignmentCenter;
Also don't forget to add the subview to the header:
[theHeader addSubview:headerLabel] and to put a height for your header either within CGRectMake or defined (e.g. #define HEADER_HEIGHT 52.0f)
Let me know if it worked!
Related
I want to put my table view background below the nav bar. When I try to change frame nothing happens..
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, -100, 320, 480)];
imageView.image = self.theme.bgImage;
[self.tableView setBackgroundView:imageView];
In the docs it says:
A table view’s background view is automatically resized to match the
size of the table view.
So I think it's alway resized again by the framework.
Add UIImageview as subview to view and set appropriate image.Place imageview behind tableview. Make tableview background nil. Then try to change frame. This may help you.
As I understand it, the UITableViewCellAccessoryTypeCheckmark appears when the row is tapped/untapped.
However, I would like to make an accessory that is always visible. Like a Checkbox or something of the sort. This is because i want to display additional information if the row is selected but if the Checkbox at the right end of the row is tapped, a tick should appear in it.
Sorry if I was not very clear. Please ask me for any clarifications.
Thanks!
You have to create your custom accessory view. In that view you add two UIImageView, and give a tag for the checkbox.
On create:
#define CHECKBOX_TAG 123
UIView *customAccessoryView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)] autorelease];
UIImageView *otherInfo = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)] autorelease];
UIImageView *checkbox = [[[UIImageView alloc] initWithFrame:CGRectMake(30, 0, 30, 30)] autorelease];
checkbox.tag = CHECKBOX_TAG;
[customAccessoryView addSubview:otherInfo];
[customAccessoryView addSubview:checkbox];
cell.accessoryView = customAccessoryView;
On display, if selected, set the checkbox hidden to NO:
UIImageView *checkbox = [cell.accessoryView viewWithTag:CHECKBOX_TAG];
if(selected){
checkbox.hidden = NO;
}else{
checkbox.hidden = YES;
}
You can achieve this by using button.Create a button in cell with unchecked checkbox image and when user click on this button change the image of the button to check.
If you want a UIKit use accessoryType property of a UITableViewCell.
#property(nonatomic) UITableViewCellAccessoryType accessoryType
If you really want a custom one use accessoryView.
#property(nonatomic, retain) UIView *accessoryView
Make a button and add it to your acceessoryView: and use it like a check box...
this will resolve your problem
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!
I am an iOS development newbie. I have a settings screen which is a UITableView. I want to add some explanation to it. I am using the following code to do it, but it skews up the text completely. Any idea what I am doing wrong?
UILabel *subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0, 300, 175)];
subjectLabel.font = [UIFont systemFontOfSize:16.0];
subjectLabel.numberOfLines = 0;
subjectLabel.font = [UIFont fontWithName:#"Arial Rounded MT Bold" size:(10.0)];
subjectLabel.backgroundColor = [UIColor clearColor];
//bodyLabel.textAlignment = UITextAlignmentLeft;
subjectLabel.text = #"mytext";
settingTableView = [[[UITableView alloc] initWithFrame:CGRectMake(0,0, 320, 370) style:UITableViewStyleGrouped] autorelease];
settingTableView.dataSource = self;
settingTableView.delegate = self;
[settingTableView addSubview:subjectLabel];
[self.view addSubview:settingTableView];
A tableViewHeader is a UIView which is set as the tableViewHeader property of a tableView. If you want to have a UILabel in a header view, make a separate UIView (either in code, or in a nib), and set it as the tableView.tableHeaderView property. More information can be found here: TableView Reference. Hope that helps!
create a view in your view controller and add your lable to that and bind it ...
IBOutlet UIView *headerView1;
and add this code
settingTableView.tableHeaderView = headerView1;
Suggestion1 : You could have create a separate view which contains your UILabel and place above the UITableView and place your tableView y position would be from the height of the UIView.
Remark : This is useful because when you scroll the tableView the default header will be stick to top.
Suggestion2 : you can use viewForHeaderInSection delegate method. where you can create a view and add the UILabel. viewForHeaderInSection returns the UIView, which you can return your view which contains the UILabel
Remark : when you scroll the tableView the default header will move along with your tableView
I would like to achieve a similar effect:
http://imageshack.us/m/695/3715/img0419s.png
My initial idea was to create something like presentend in this schema http://imageshack.us/m/9/9227/img0413.png. Ie a ViewController with 2 subviews: a classical one with some information, and a tableView below which should scroll over the previous view.
But I realized that dividing the main view this way couldn't allow my tableview to scroll over the first view.
So I'm asking how this effect is possible. Maybe by setting a transparent header ?
Thanks for your help
Following the teriiehina's advise, here is how I dit it :
In my UITableViewController, I set a 50px contentInset and a transparent color to my tableView.
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.contentInset = UIEdgeInsetsMake(50,0,0,0);
I added an additional view on the top of the view (same size than the contentInset)
TTView *test = [[TTView alloc] init];
test.frame = CGRectMake(0, 0, 320, 50);
test.backgroundColor = [UIColor grayColor];
[self.view addSubview:test];
Finally, in order to let my tableview scroll over the additional view, I brought it in the front
[self.view bringSubviewToFront:self.tableView];
Now I just have to set a custom color for my cells.
A dirty trick here:
Add the UIView that contains the name first
Add a UIScrollView with clipBounds = NO. That view will contain the message.
That should work for you
I think you can achieve this effect using the contentInset property of the UITableView (which is a UIScrollView subclass) and presenting the tableView at first with a programmatic scroll.