I have stumbled over a problem while adding a button to my table view cell.
Let me explain after I have added the code:
- (UITableViewCell *) TableView: (UITableView *) table view cellforoutoundpath: (NSIndexPath *) indexPath { Fixed NSString * CellIdentifier = @ "cell"; Radiocoust cell * cell = (radio cutmass *) [Tableview decouple reuble cell wuth identifier: cell identifier]; If (cell == blue) {cell = [[[Radiocustom cl alok] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cell identifier] autorelease]; [Cell set Charl image: [UIImage imageNamed: @ "p4.png"]]; UILabel * nowTitle = [Uylabel]]; NowTitle.text = @ "My Heart"; [Cell satonolite: abital]; UILBal * Artist = [UILBL Alloc]; NowArtist.text = @ "Moby"; [Cell setonouver artist: now artist]; UILBL * NextTitle = [UILBL Alloc]; NextTitle.text = @ "Only Girl (World)"; [Cell setextital: next-bit]; UILBL * Next Artist = [UILBL Alloc]; NextArtist.text = @ "Rihanna"; [Cell set advance artist: Next artist]; // my button right here UI button * button = [UI button button type with UIButtonTypeCustom]; Button.frame = CGRectMake (6, 31, 110, 20); [Set button image: [UIImage imageNamed: @ "radionorge.png"] forState: UIControlStateNormal]; [Button addTarget: Self-action: @Selector (touched) for control events: UIControlEventTouchUpInside]; [Cell.backView addSubview: buttons]; } Return Room; }
and act for action for the "touched" button.
- (zero) touched: (ID) Sender {// here I want to get UILABLELES for each cell. Like Artist}
You see, I want to get the UILL-book for each cell in the touch-function. I know that you use the sender as a type of indicator But I do not know how to
First of all, you want to set the tag properties for each label. Using a #define or const is a good idea, but for simplicity, I would recommend that you use 1, 2, 3 and 4 for each UILB in order to appear in the code.
This is what action codes you are making should look like this. (You may need to make a small change in it.)
- (zero) touched: (ID) Sender {// Here I want to get UILAblays for each cell. Like now the artist ([sender hackedAfklaah: [UIButton class]]) {UIButton * button = (UIButton *) sender; UIView * contentView = button.superview; UIView * viewWithTag1 = [Content View Views DescriptionTag: 1]; If ([viewWithTag1 isKindOfClass: [UILabel class]]) {UILabel * titleLabel = (UILabel *) View Details 1 tag; // Now you have the title label} // Repeat the above for each tag. }
An overview: You are leaking too many objects in the code every time you update a cell, you do not need to allocate a group of new labels is. Just use something like:
cell.nowTitle.text = @ "in my heart";
Comments
Post a Comment