HELP! tableView:accessoryTypeForRowWithIndexPath

Discussion in 'iOS Programming' started by lJoct03, Jan 23, 2012.

  1. lJoct03 macrumors member

    Joined:
    Nov 18, 2009
    #1
    Code:
    - (UITableViewCellAccessoryType)tableView:(UITableView *)tv accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
    {
        //return UITableViewCellAccessoryDetailDisclosureButton;
        //return UITableViewCellAccessoryDisclosureIndicator;
        return UITableViewCellAccessoryNone;
    }
    How do i do this?
    Any help would be greatly appreciated.
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Set the property on the cell in your cellForRowAtIndexPath method and remove the old method that it doesn't like.

    Code:
    cell.accessoryType = UITableViewCellAccessoryNone;
     
  3. lJoct03 thread starter macrumors member

    Joined:
    Nov 18, 2009
    #3
    Here's my cellForRowAtIndexPath. Where do i remove the old method that it doesn't like? And what is the old method that it doesn't like? Thanks for the help.

    Code:
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
           cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
        
        // Set up the cell...
        if(searching) 
            cell.textLabel.text = [copyListOfItems objectAtIndex:indexPath.row];
        else {
        //First get the dictionary object
    	NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
        NSArray *array = [dictionary objectForKey:@"News"];
        NSString *cellValue = [array objectAtIndex:indexPath.row];
        cell.textLabel.text = cellValue;
        }
        return cell;
    }    
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    This is the method that has been deprecated:

    tableView:accessoryTypeForRowWithIndexPath: in <RootViewController: 0x685f100>

    If you want none of the cells to be selectable then add the code I showed like this:

    Code:
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
           cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.accessoryType = UITableViewCellAccessoryNone;
        }
        
        // Set up the cell...
        if(searching) 
            cell.textLabel.text = [copyListOfItems objectAtIndex:indexPath.row];
        else {
        //First get the dictionary object
    	NSDictionary *dictionary =[listOfItems objectAtIndex:indexPath.section];
        NSArray *array = [dictionary objectForKey:@"News"];
        NSString *cellValue = [array objectAtIndex:indexPath.row];
        cell.textLabel.text = cellValue;
        }
        return cell;
    }
     

Share This Page