i have a my requirement disable the table cell.i have controls on that cell like(textFeild,imageview,button).when i access one control it prefprms another action so plz help me . thanks in advance.
It is not clear what you want exactly. If you just want to disable the cell i think you mean this
cell.userInteractionEnabled = NO;
But what do you mean by when i access one control it performs another action ?
I would suggest using custom UITableViewCells. Put all your controls on custom cells, that way all the events pertaining to that controls would be called in the actions in your custom cell class. In the tableView class you just don't have to give any implementation for didSelectRowAtIndexPath. That way your controls on the cells would be clickable.
It could also apply a color effect:
UIView *lab = [[UIView alloc] initWithFrame:cell.frame];
[lab setBackgroundColor:[UIColor lightGrayColor]];
cell.backgroundView = lab;
Related
I'm just starting out working on my first iOS app. How do you create a UITableViewCell that contains a UITextField that looks like the Title and Location fields when adding an event within the Calendar application? Are there any handy third-party components for doing this?
I can see that the table view has two grouped items and that the text fields have some placeholder text, it's more about how to go about making the text fields take up 100% of their parent table view cells.
Thanks in advance for any help.
You need to add the UITextView as a subview of the UITableViewCell. In the cellForRowAtIndexPath: method do the following:
Create a UITextView as you normally would:
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,300,40)];
NB: the numbers are the x, y, width, height. Modify these to fit your own app.
Add it as a subview of the cell:
[cell addSubview:textView];
If you only want specific cells to have the textview you will need to do something like
//Use the if statement to specify which row(s) you want the UITextView to appear in
if (indexPath.row == 1) {
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,300,40)];
[cell addSubview:textView];
}
The Table View Programming Guide for iOS has a section called A Closer Look at Table-View Cells. It describes two techniques for customizing a table-view cell: with code and using a pre-built nib. I think it has a lot of information you will be interested in.
I have a custom UITableViewCell which fills the cell with a background PNG and a label.
When the user selected the cell, I wish to have the back ground change for an instant to visually give them indication that the row was selected. Similar to the default behavior when a custom cell is not used.
How is that done?
You can try this tutorial:
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
Posting as answer so this is correct (originally from BahaiResearch.com):
In this scenario the correct answer is to use the following, when setting the image originally:
image.HighlightedImage = [UIImage ..];
Otherwise you are loading images when the highlight event occurs and in theory there's a slight delay, etc.
let me clear first do you wish to change the backgroundimage.png??
if yes and you are using UIImageView for that then you can write following code in rowDidSelected event..
UIImageView *myImageView = [Cell viewWithTag:1]; //Tag is given in Interface Builder for the ImageView
myImageView.image = [[UIImage alloc] imageNamed:#"newimage.png"];
I am trying to get a label to show over part of the grey-space in a grouped UITableView, but it only appears if the label is in a cell. I have tried adding the label as a subview of both the ViewController and the tableView and bringing it to front, but in either case it only shows over the white-space of a cell, not over the grey-space of the background. I know that I am a complete noob at Obj-C and iPhone dev and that this is a really stupid question, but I would really appreciate any help.
My code:
CGRect cgRct = CGRectMake(180, 20, 100, 50);
label = [[UILabel alloc] initWithFrame:cgRct];
label.text = #"Editting On";
label.textColor = [UIColor redColor];
label.hidden = TRUE;
//Display label
[tableView addSubview:label];
[tableView bringSubviewToFront:label];
There is probably a way to get this to work, but I'm betting that what you're trying to do is much simpler than you're making it. So, maybe explain what you want to do.
The first thing I see is you've set the hidden property to TRUE (you should be using YES, instead of TRUE by the way). If the label is hidden, you won't be able to see it, so either remove that line or change its parameter to NO.
Next, I should point out that you can add custom views for the table header and footer. You can even use custom views for section headers and footers. If what you want is a custom cell, then you'll want to either code that by hand or create a custom cell view in Interface Builder and then load it dynamically.
If what you are wanting, however, is to overlay the entire view with another view, then it will work to add the view to the top level controller's view--which is to say if you have a navigation based app, for example, you can access the navigation controller and add your view as a subview.
[[[self navigationController] view] addSubview:label];
HTH.
I am creating an application. I have to implement a bookmark feature, and adding one should be similar to this:
mmm http://img534.imageshack.us/img534/9859/schermafbeelding2010040a.png
I want editable UITableViewCells for text input. I was wondering if there is an easier way then embedding a UITextField into a UITableViewCell. And if not, can someone explain how I can use the UITextField inside it? Thanks
There isn't an easier way, you will have to subclass UITableViewCell and add in the UITextField. Here is a tutorial for using a UITextView should be about the same as a UITextField.
You can just add a textfield to the contentView of your cell, and an (X) button to the accessoryView of your cell. You could do that in a UITableView subclass which would let you add keep track of your added elements with instance variables or properties.
I found this helpful: Cocoa With Love: Easy custom UITableView drawing
Like this:
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:#"myEditableCellId"];
label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
[cell.contentView addSubview:label];
You can use https://github.com/escoz/QuickDialog for simple cases like that. But you probably need to write your own custom cell if it's more complex.
I have a tableView populated with custom tableViewCells. The cells are not subclasses, they are merely tableViewCells which have had a lot of tweaking and "subview-adding"(done in the cellForRowAtIndexPath method). The problem occurs when i tap the edit button. Have a look:
PICTURE_1
I know the "delete badge" is hovering above the text, I'll fix that later. My problem is that the "delete badge" and the reorderControl assumes the color of the table's backgroundColor(which I've set to be the same as the top row). I've tried doing this:
cell.accessoryView.backgroundColor = [UIColor clearColor] But it doesn't help which I assume is because the "delete badge" and reorderControl are not displayed in the accesoryView. My problem does not only count for the badge and the reorder control. It also counts for the delete button that appears when I press the delete-badge.
So do anybody know how to fix this? I'm really stuck here.
Thanks.
Looks like you need to assign a background view to your cells, and give that a background color:
cell.backgroundView = [[[UIView alloc] initWithFrame: cell.bounds] autorelease];
cell.backgroundView.backgroundColor = [UIColor gray];