I'm adding multiple tableviews into the scrollview based on the array count...and the code is here
int currentX = 3;
for(int i=0;i<[restNameArray count]; i++)
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(currentX, 0, 150, 35)];
button.tag = i+1;
//[button setUserInteractionEnabled:NO];
[button addTarget:self action:#selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[UIImage imageNamed:#"ohris_applytics_ipad_middle_oc.png"] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont fontWithName:#"HelveticaNeue-CondensedBold" size:15.0f];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setTitle:[NSString stringWithFormat:#"%#", [restNameArray objectAtIndex:i]] forState:UIControlStateNormal];
restaurantTable = [[UITableView alloc] initWithFrame:CGRectMake(currentX, 35, 150, 310) style:UITableViewStylePlain];
[restaurantTable setTag:i+1];
[restaurantTable setBackgroundColor:[UIColor whiteColor]];
restaurantTable.delegate = self;
restaurantTable.dataSource = self;
[scrollView addSubview:button];
[scrollView addSubview:restaurantTable];
NSLog(#"tag %d",restaurantTable.tag);
currentX = restaurantTable.frame.size.width+currentX+3;
[tagArray addObject:[NSString stringWithFormat:#"%d", restaurantTable.tag]];
}
NSLog(#"aaaa %#", tagArray);
[scrollView setContentSize:CGSizeMake(currentX, 349)];
It is showing fine in the simulator. And i need to populate the tableviews with array.
And the code at cellforrowatindexpath is
if(tableView == restaurantTable){
for (int i =0;i<[tagArray count];i++)
{
table1Array = [[[restSalesArray objectAtIndex:i]componentsSeparatedByString:#","]mutableCopy];
NSLog(#"Sales array :%d %#", i, table1Array);
cell.textLabel.text = [formatter stringFromNumber:[NSNumber numberWithInteger:[[table1Array objectAtIndex:indexPath.row]intValue]]];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
}
}
But the problems is, it is populating only in the last tableview.. remaining are empty... plz help me out guys....
It is ok what you are trying to do. But you are overriding the restaurantTable variable in your for loop. So the variable is the last table view. You need to add them to an array or seperate variables to be able to compare with if in you cellForRowAtIndexPath method.
_allTableViews is defined in your header file
you for loop
_allTableViews = [NSMutableArray array];
for (.....) {
.
.
.
UITableView *tableView = [[UITableView alloc] initWith....];
.
.
.
[_allTableViews addObject tableView];
}
cellForRowAtIndePath
NSInteger tableIndex = [_allTableViews indexOfObject:tableView];
// Now you have the index of table view
switch (tableIndex) {
case 0:
// first table
break;
case 1:
// second table
break;
default:
break;
}
You need to compare each tableView either by its outlet name or tag.
As :
if(tableView == _restaurantTableOutlet){
...
}
else if(tableView == _barTableOutlet){
...
}
else if(tableView == _loungeTableOutlet){
...
}
You are storing each table view into restaurantTable, so the references to previous table views are lost. Either store them all in an array, or don't store any of them
Why are you checking if(tableView == restaurantTable)? You should check the tables by tag and work with each one separately
You have to first assign tag for each tableView. Then you can get selected row of particular table by following code:-
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int tableTag = tableView.tag;
if(tableTag==0)
{
//do something here
}
else if(tableTag==1)
{
//do something here
}
}
Related
I have 7 buttons on my storyboard, I have associated a tag number to each of the button. And all the buttons are hooked up to a single IBAction.
In my action method I have a switch statement like switch ([sender tag])
which run the appropriate action according to the tag. This is all working.
But I want to add a functionality where selected button is highlight and rest of them in normal state.
You can create property with tags:
#property (nonatomic, strong) NSArray *tags;
Somewhere (for example, in viewDidLoad) initialize it with values used in storyboard:
tags = #[#1, #2, #3, #4, #5]
And select buttons using this tags
- (IBAction)buttonPressed:(UIButton *)sender {
for (int i = 0; i < tags.count; i++) {
UIButton *button = [self.view viewWithTag:tags[i]];
button.selected = (button.tag == sender.tag);
}
}
Or you can create IBOutlets for every 7 buttons and create array for it.
array = #[outlet1, ..., outlet7]
And select buttons using outlets
- (IBAction)buttonPressed:(UIButton *)sender {
for (int i = 0; i < array.count; i++) {
UIButton *button = array[i];
button.selected = (button.tag == sender.tag);
}
}
Hope this can give you some idea:
- (void)setupButtons {
for (int i = 0; i < 7; i++) {
CGFloat width = self.view.frame.size.width / 7;
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(i * width, 100, width, 30)];
[self.view addSubview:button];
button.tag = 1000 + i;
[button setTitle:[NSString stringWithFormat:#"%d", i] forState:UIControlStateNormal];
button.backgroundColor = [UIColor redColor];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
[button addTarget:self action:#selector(buttonClicked:) forControlEvents:UIControlEventTouchDown];
if (i == 0) {
// default first button selected
button.selected = YES;
}
}
}
- (void)buttonClicked:(UIButton *)sender {
for (int i = 0; i < 7; i++) {
UIButton *button = [self.view viewWithTag:(1000+i)];
button.selected = (button.tag == sender.tag);
}
}
I have array of images here i am doing check and uncheck the images finally i have delete button which are the images i check i need to remove the images from array based on the button selection
here is my code
- (IBAction)delete_btn_touch:(id)sender {
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
for(int i=0; i<_GalleryimageArry.count;i++){
_imageV = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.view.frame) * i/2*0.6, 0, 100, 100)];
self.Crossbtn =[[UIButton alloc]initWithFrame:CGRectMake(_imageV.image.size.width/2+80,0,20,20)];
UIImage *btnImage = [UIImage imageNamed:#"unselectimag"];
[self.Crossbtn setImage:btnImage forState:UIControlStateNormal];
_imageV.contentMode = UIViewContentModeScaleAspectFill;
_imageV.image = [_GalleryimageArry objectAtIndex:i];
[_imageV setUserInteractionEnabled:YES];
_imageV.tag = i;
self.Crossbtn.tag =i;
[self.Crossbtn addTarget:self action:#selector(deleteImage:) forControlEvents:UIControlEventTouchUpInside];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(imageTapMethod:)];
[_imageV addGestureRecognizer:tap];
[self.imageV addSubview:self.Crossbtn];
[self.imageGalleryscroll addSubview:_imageV];
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}
self.imageGalleryscroll.delegate = self;
index=0;
self.imageGalleryscroll.contentSize = CGSizeMake(CGRectGetWidth(self.view.frame) * _GalleryimageArry.count/2*0.7, CGRectGetHeight(self.imageGalleryscroll.frame));
[self.imageGalleryscroll setPagingEnabled:YES];
[self.imageGalleryscroll setShowsHorizontalScrollIndicator:NO];
self.imageGalleryscroll.alwaysBounceVertical = NO;
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
-(void)deleteImage:(UIButton *)sender{
btn = (UIButton *)sender;
self.add_delete_view.hidden =YES;
self.deleteview.hidden=NO;
if( [[btn imageForState:UIControlStateNormal] isEqual:[UIImage imageNamed:#"unselectimag"]])
{
[btn setImage:[UIImage imageNamed:#"Crossimg"] forState:UIControlStateNormal];
[btn setSelected:YES];
[btn setTag:index];
}
else
{
[btn setImage:[UIImage imageNamed:#"unselectimag"] forState:UIControlStateNormal];
// other statements
self.selectedimages =#"No";
image = [self.GalleryimageArry objectAtIndex:index];
[self.GalleryimageArry addObject:image];
}
NSLog(#"%#", self.GalleryimageArry);
}
- (IBAction)delete_all_img_btn_touch:(id)sender {
// self.view (change it with your button superview)
if (btn.selected) {
[self.GalleryimageArry removeObjectAtIndex:index];
}
//here i need to removeObjectAtIndex:index based on the how many button are selected
}
any one help me to solve this issues
thanks in advance
Use the following code, where you want to clear the back stack of controllers.
-(void)clearStack
{
NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers];
[navigationArray removeAllObjects];
//[navigationArray removeObjectAtIndex: 2];
self.navigationController.viewControllers = navigationArray;
}
i have a class loginViewController which has table contents. i have loaded a custom cell to each row of the table. in method cellForRowAtIndexPath i have created a button for each row and asigned it a tag value. clicking on this button takes us to new view controller logininsidesViewController. Now in logininsidesViewController class i want to access the button tag i created earlier.what should i do?
loginViewController.m class
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
customcell *cell=(customcell*)[tableView dequeueReusableCellWithIdentifier:#"cellcstm"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:#selector(customActionPressed)
forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[UIImage imageNamed:#"add_black.png"] forState:UIControlStateNormal];
button.frame = CGRectMake(275 ,9, 25, 25);
[cell addSubview:button];
if (cell==nil)
{
//[tableView registerNib:[UINib nibWithNibName:#"customcell" bundle:nil] forCellReuseIdentifier:#"cellcstm"];
NSArray *arr12=[[NSBundle mainBundle]loadNibNamed:#"customcell" owner:self options:nil];
cell=[arr12 objectAtIndex:0];
}
for (int i=0; i<=indexPath.row; i++)
{
cell.selectionStyle=UITableViewCellEditingStyleNone;
}
if (indexPath.row==0)
{
cell.lbl.hidden=YES;
UILabel *l=[[UILabel alloc]init];
l.text=#"Login Templates";
l.frame=CGRectMake(100, 15, 180, 28);
[cell.contentView addSubview:l];
}
if (indexPath.row==1)
{
button.tag=1;
cell.img.image=[UIImage imageNamed:#"facebook.png"];
cell.lbl.text=#"Facebook";
[cell.contentView addSubview:button];
}
if (indexPath.row==2)
{
button.tag=2;
cell.img.image=[UIImage imageNamed:#"g+.png"];
cell.lbl.text=#"Google";
[cell.contentView addSubview:button];
}
if (indexPath.row==3)
{
button.tag=3;
cell.img.image=[UIImage imageNamed:#"youtube.png"];
cell.lbl.text=#"Youtube";
[cell.contentView addSubview:button];
}
if (indexPath.row==4)
{
button.tag=4;
cell.img.image=[UIImage imageNamed:#"twitter.png"];
cell.lbl.text=#"Twitter";
[cell.contentView addSubview:button];
}
if (indexPath.row==5)
{
button.tag=5;
cell.img.image=[UIImage imageNamed:#"flicker.png"];
cell.lbl.text=#"Flicker";
[cell.contentView addSubview:button];
}
else
{
cell .textLabel.text= [logarr objectAtIndex:indexPath.row];
}
return cell;
}
i want to access the button.tag in my logininsidesViewController class. plz help
In continuation with Viruss's answer you can create a property with integer type in logininsidesViewController class and pass that from button click.
-(IBAction) customActionPressed:(id)sender{
NSLog(#"button tag:%d",[sender tag]);
logininsidesViewController *objLoginInside = [[logininsidesViewController alloc] initWithNibName:#"logininsidesViewController" bundle:nil];
objLoginInside.buttonTag = sender.tag;
[self.navigationController pushViewController:objLoginInside animated:NO];
}
Add One target method to your buttons and access it with tags,
In cellForRow method Update to this.
[button addTarget:self action:#selector(customActionPressed:) forControlEvents:UIControlEventTouchUpInside];
You can access here with tag,
-(IBAction) customActionPressed:(id)sender{
NSLog(#"button tag:%d",[sender tag]);
}
You are adding your button on cell and again you're adding it on cell's contentView correct that is the problem.
If you want adding it in cell.contentView you must provide allocation in each if condition and then add it
Edit: Do smart coding
viewDidLoad()
[self.myTableView registerNib:[UINib nibWithNibName:#"CViewCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
arImage = #[#"facebook.png", #"g+.png", #"twitter.png", #"flicker.png" ];
arLables = #[#"Facebook", #"GooglePlus", #"Tweeter", #"Flicker"];
cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell * cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:#selector(customActionPressed) forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[UIImage imageNamed:#"add_black.png"] forState:UIControlStateNormal];
button.frame = CGRectMake(275 ,9, 25, 25);
if (indexPath.row==0)
{
cell.lblText1.hidden=YES;
UILabel *l=[[UILabel alloc]init];
l.text=#"Login Templates";
l.frame=CGRectMake(100, 15, 180, 28);
[cell.contentView addSubview:l];
}
if ( indexPath.row > 0 && indexPath.row <= 5) {
button.tag = indexPath.row;
cell.imageView.image=[UIImage imageNamed:arImage[indexPath.row - 1]];
cell.textLabel.text=[arLables objectAtIndex:indexPath.row - 1];
[cell.contentView addSubview:button];
} else {
cell.textLabel.text= [logarr objectAtIndex:indexPath.row];
}
return cell;
}
Ok simple question but can't find an answer.
I'v got a button to save information in my app.
I have
NSMutableArray *textFields = [[NSMutableArray alloc] initWithCapacity:5];
UITextField *textField = nil;
This is the information i want to save, i'v got 5 textfields in textFields mutablearray.
[save addTarget:self action:#selector(saveInfo)
forControlEvents:UIControlEventTouchUpInside];
and
-(void)saveInfo {
[[[NSUserDefaults standardUserDefaults] setValue: ????? forKey:#"Phone"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
The question is how to access and get information from like textFields[1].text in my saveInfo void ?
Ok To get things a little bit clearer i'v added the whole class. its not very big, and maybe someone could see thats the problem with my implementation .
#implementation Settings
- (id)init: (TableViewController*) TableControll {
NSMutableArray *textFields = [[NSMutableArray alloc] initWithCapacity:5];
UITextField *textField = nil;
for (int i = 0; i < 3; i++) {
textField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 0.0f+(i*35), 120.0f, 30.0f)];
textField.backgroundColor = [UIColor whiteColor];
[textField setBorderStyle:(UITextBorderStyleRoundedRect)];
[TableControll.view addSubview:textField];
[textFields addObject:textField];
[textField release]; textField = nil;
}
UITextField *textName = textFields[0];
textName.placeholder = #"Vardas";
UITextField *textNo = textFields[1];
textNo.placeholder = #"Telefonas";
textNo.keyboardType = UIKeyboardTypeNumberPad;
UITextField *textPin = textFields[2];
textPin.keyboardType = UIKeyboardTypeNumberPad;
textPin.placeholder = #"Pin";
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(150, 20, 160, 30);
[button setTitle:#"Advanced settings" forState:UIControlStateNormal];
[TableControll.view addSubview:button];
UIButton *save = [UIButton buttonWithType:UIButtonTypeRoundedRect];
save.frame = CGRectMake(150, 60, 160, 30);
[save setTitle:#"Save settings" forState:UIControlStateNormal];
[TableControll.view addSubview:save];
[button addTarget:self action:#selector(goAdvanced)
forControlEvents:UIControlEventTouchUpInside];
[save addTarget:self action:#selector(saveInfo)
forControlEvents:UIControlEventTouchUpInside];
return self;
}
-(void)goAdvanced {
AppDelegate *newControll = (AppDelegate*)[UIApplication sharedApplication].delegate;
[newControll ChangeController];
}
-(void)saveInfo {
for(int i=0;i<5;i++) {
UITextField *tempTxtField=[_textFields objectAtIndex:i];
NSLog(#"do it %#",tempTxtField.text);
}
}
#end
What you'd want to do if you are using interface builder is create a bunch of IBOutlet for your textfields instead of keeping them in an array. Check out this: tutorial
Now it looks like you're creating things by hand, so in this case, you probably just want to declare your array as #property so it can be accessed by your save method.
To access the text property of a UITextField from your array you would write:
((UITextField *)[textFields objectAtIndex:1]).text
If you want to access the all textfield,
for(int i=0;i<[textFields count];i++) {
UITextField *tempTxtField=[textFields objectAtIndex:i];
NSlog(#"%#",tempTxtField);
}
-(void)saveInfo {
NSMutableArray *tempArr = [NSMutableArray array];
for(int i = 0; i < [textFieldsArray count]; i++){
[tempArr addObject:[(UITextField*)[textFieldsArray objectAtIndex:i]text]];
}
[[[NSUserDefaults standardUserDefaults] setValue:tempArr forKey:#"Phone"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
I'm not entirely sure I understand your question, but this is what I would do in your place. Instead of creating an array to hold each of the textfields, I'd just assign them a custom tag. Any number will work (although avoid zero since that's the default tag on all views). So your init method would look like this:
for (int i = 0; i < 3; i++) {
textField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 0.0f+(i*35), 120.0f, 30.0f)];
textField.backgroundColor = [UIColor whiteColor];
textField.tag = (i+1);
[textField setBorderStyle:(UITextBorderStyleRoundedRect)];
[TableControll.view addSubview:textField];
[textField release]; textField = nil;
}
Then in the code that you want to reference the text field, you'd retrieve the view by its tag, making sure to cast it as UITextField.
-(void)saveInfo {
for(int i=0;i<5;i++) {
UITextField *textField = nil;
UIView *view = [self.view viewsWithTag:i];
if ([view isKindOfClass:[UITextField class]]) {
textField = (UITextField *) view;
NSLog(#"do it %#",textField.text)
}
}
}
NOTE: I'm referencing self.view but you'll need to reference TableControll.view. You'll need to retain a reference to it somewhere in your code. Also, I'd recommend your start using ARC.
Hope that helps! Good luck!
I have two buttons inside sectioned tableview cell thumbs up and thumbs down. Initially image of both button is not selected. When I select thumbs up button its image become thumbs up selected and other one become thumbsdown not selected and vice versa.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSLog(#"mod:numberOfSectionsInTableView");
NSLog(#"[preferences count]=%d",[preferences count]);
return [preferences count];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.choices count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexpath
{
NSLog(#"cellForRowAtIndexPath: DISPLAY TEST");
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
NSLog(#"Text is: %#", [choices objectAtIndex:indexpath.row]);
NSLog(#"CHOICE AT INDEX PATH IS: %#",[choices objectAtIndex:indexpath.row %[choices count]]);
cell.textColor = [UIColor whiteColor];
cell.backgroundColor = [UIColor blackColor];
// Thumbs up button.
//UIButton *thumbsUp = [[UIButton alloc]init];
thumbsUp = [UIButton buttonWithType:UIButtonTypeCustom];
[thumbsUp setTag:(indexpath.row+(indexpath.section * 50))];
[thumbsUp addTarget:self action:#selector(thumbUp_ButtonClicked:event:)
forControlEvents:UIControlEventTouchUpInside];
[thumbsUp setTitle:#"" forState:UIControlStateNormal];
thumbsUp.frame = CGRectMake(150.0, 20, 20, 15);
[thumbsUp setBackgroundImage:[UIImage imageNamed:#"thumbsup_not_selected.png"]
forState:UIControlStateNormal];
//NSLog(#"------------------>TAG TEST : %d",(indexpath.row+(indexpath.section * 50)));
[cell.contentView addSubview:thumbsUp];
// Thumbs down button
thumbsDown = [UIButton buttonWithType:UIButtonTypeCustom];
[thumbsDown addTarget:self action:#selector(thumbDown_ButtonClicked:event:)
forControlEvents:UIControlEventTouchUpInside];
[thumbsDown setTitle:#"" forState:UIControlStateNormal];
thumbsDown.frame = CGRectMake(200, 20, 20, 15);
[thumbsDown setTag:indexpath.row+120];
[cell.contentView addSubview:thumbsDown];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[thumbsDown setBackgroundImage:[UIImage imageNamed:#"thumbsdown_not_selected.png"]
forState:UIControlStateNormal];
}
NSLog(#"------------> TAG TEST %d",thumbsUp.tag);
cell.text = [choices objectAtIndex:(indexpath.row % [choices count])];
NSLog(#"HELLO FOR TESTING");
return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
if (sectionTitle == nil) {
return nil;
}
// Create label with section title
UILabel *label = [[[UILabel alloc] init] autorelease];
label.frame = CGRectMake(15, 10, 300, 25);
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
label.shadowColor = [UIColor whiteColor];
label.shadowOffset = CGSizeMake(0.0, 1.0);
label.font = [UIFont boldSystemFontOfSize:16];
label.textAlignment = UITextAlignmentLeft;
label.text = sectionTitle;
// Create header view and add label as a subview
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(12, 0, 300, 60)];
[view autorelease];
[view addSubview:label];
//[view addSubview:segmentedControl];
view.backgroundColor = [UIColor grayColor];
return view;
}
//Thumbs Up Button Action
- (IBAction)thumbUp_ButtonClicked:(id)sender event:(id)event
{
NSLog(#"Thumbs Up Check!");
UIButton *button = (UIButton *)sender;
UITableViewCell *cell = (UITableViewCell *) [[button superview] superview];
NSIndexPath *indexPath = [myTable indexPathForCell:cell];
NSLog(#"indexpath =%d",indexPath.row);
//[button setTag:indexPath.row+(indexPath.section * 50)];
int cTag = [sender tag];
NSLog(#"------>TAG : %d", cTag);
NSLog(#"------> Calculated TAG %d",indexPath.row+(indexPath.section * 50));
if(cTag == (indexPath.row+(indexPath.section * 50)))
{
NSLog(#"BUTTON COUNT:");
[button setBackgroundImage:[UIImage imageNamed:#"thumbsup_selected.png"]
forState:UIControlStateNormal];
}
NSInteger section = indexPath.section;
NSInteger row = indexPath.row;
//int row = button.tag;
NSLog(#"SECTION IS:%d",section);
NSLog(#"ROW IS: %d",row);
NSArray *array = cell.contentView.subviews;
NSLog(#"NUMBER OF OBJECTS: %d",[array count]);
UIButton *test = (UIButton *)[array objectAtIndex:2];
[test setBackgroundImage:[UIImage imageNamed:#"thumbsdown_not_selected.png"]forState:UIControlStateNormal];
}
Due to issue with tag of button while I change image of one button several buttons are changing. If any one can please find a solution it will be helpful.... tag is setting for buttons in sections which we can view.
The reason is the bad use of the recycling/reuse mechanism (as with 75% of questions about UITableView…)
Go read the Table View Programming Guide in Apple's doc (and search SO and the web for any question related to tableview and the reuse mechanism)
Corrected the issue by creating buttons outside and inside if(cell == nil). Also created a mutable dictionary to keep the current state of the button.....