Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change the background color of two uibutton on single click action in iPhone?
    primarykey
    data
    text
    <p>I'm new to iPhone app developing.In my app I'm using tableview.In tableview I'm using two uibuttons one in <strong>white color</strong> and another one in <strong>graycolor</strong>.If I click gray color button it should changed to white color and another button should changed to gray color on same time.</p> <p>This is my code:</p> <pre><code> -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; ExampleCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell=nil; if(cell == nil) { cell = [[ExampleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } if(indexPath.row == 0) { postbtn = [UIButton buttonWithType:UIButtonTypeCustom]; [postbtn setFrame:CGRectMake(0, 205, 160, 34)]; [postbtn setBackgroundColor:[UIColor whiteColor]]; [postbtn setTitle:[NSString stringWithFormat:@"%@ POST",[AppDelegate.profileDic objectForKey:@"posts"]] forState:UIControlStateNormal]; [postbtn.titleLabel setFont:[UIFont fontWithName:@"Verdana-Bold" size:10]]; [postbtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; [postbtn setTag:1001]; [postbtn addTarget:self action:@selector(reloadAction:) forControlEvents:UIControlEventTouchUpInside]; [cell addSubview:postbtn]; likebtn = [UIButton buttonWithType:UIButtonTypeCustom]; [likebtn setFrame:CGRectMake(160, 205, 160, 34)]; [likebtn setBackgroundColor:[UIColor lightGrayColor]]; [likebtn setTitle:[NSString stringWithFormat:@"%@ LIKE",[AppDelegate.profileDic objectForKey:@"likes"]] forState:UIControlStateNormal]; [likebtn.titleLabel setFont:[UIFont fontWithName:@"Verdana-Bold" size:10]]; [likebtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; [likebtn setTag:1002]; [likebtn addTarget:self action:@selector(reloadAction:) forControlEvents:UIControlEventTouchUpInside]; [cell addSubview:likebtn]; } )}; -(void)reloadAction:(id)sender { if ([sender tag] == 1001) { [postbtn setBackgroundColor:[UIColor whiteColor]]; [likebtn setBackgroundColor:[UIColor lightGrayColor]]; AppDelegate.selectedTab=1; [profiletableview reloadData]; } if ([sender tag] == 1002) { [postbtn setBackgroundColor:[UIColor lightGrayColor]]; [likebtn setBackgroundColor:[UIColor whiteColor]]; AppDelegate.selectedTab=2; [self likewebservice]; [profiletableview reloadData]; } } </code></pre> <p>Is there any way to change the background color of uibutton.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload