UIButton in UITableView problem?

There're some problems with your code which may be not relevant to your problem, but still You create cell contents each time cell is reused - so if you scroll your table back and forth the reused cells will contain multiple identical subviews - that's not what you want. To fixed that you must move creating contents to the creating cell block: if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier autorelease; // Create cell contents here! ... } You must not release your button - since you create it with convenience method button is autoreleased button = UIButton buttonWithType:UIButtonTypeCustom initWithFrame:CGRectMake(3, 3, 30, 30) This line may also cause problems: button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside Here you set selector that receives no parameters.

If your buttonPressed method declared is (most common way) (void) buttonPressed:(id)sender Then you must create selector as @selector(buttonPressed:) to indicate that it actually takes 1 parameter.

There're some problems with your code which may be not relevant to your problem, but still... You create cell contents each time cell is reused - so if you scroll your table back and forth the reused cells will contain multiple identical subviews - that's not what you want. To fixed that you must move creating contents to the creating cell block: if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier autorelease; // Create cell contents here! ... } ... You must not release your button - since you create it with convenience method button is autoreleased button = UIButton buttonWithType:UIButtonTypeCustom initWithFrame:CGRectMake(3, 3, 30, 30); This line may also cause problems: button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside; Here you set selector that receives no parameters.

If your buttonPressed method declared is (most common way) - (void) buttonPressed:(id)sender; Then you must create selector as @selector(buttonPressed:) to indicate that it actually takes 1 parameter.

Thanks alot for quick and so useful response. I have made changes by removing release command for the button and changing IBAction to void. – Aqueel Sep 16 '10 at 11:21 Thanks a lot for such a quick and useful response.

I have made changes by removing release for button and changing IBAction to void. Code works fine now. – Aqueel Sep 16 '10 at 11:23 so extra release must have been that problem.

IBAction is actually the same as void so it should not make any difference. However I strongly recommend to fix what I pointed at 1st comment as well - if your table is scrollable and has large data then the performance and general look may degrade eventually – Vladimir Sep 16 '10 at 11:37 sure I have already fixed it. :-) – Aqueel Sep 16 '10 at 12:37.

I have added a uibutton in every row of uitableview, Now, whenever a user clicks on any of the button in uitableview, I want to remove that button. Please help me to solve this, I have added the button tag with indexPath. Row and then fire a method that contains a mutable array, then I add the sender tag into mutable array and reload the tableview and in cell for row, I am checking whether the array contains the object, if yes I place a label else a button.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions