uttam uttam - 9 months ago 66
Objective-C Question

how to add the plus button to the right side of the table view in objective-c?

I want to add the plus button to right side of the table view to add the content of the that cell in other view.

how to add the plus button in the right side of the table view.

Answer Source
  1. Go to the iPhone Interface Guidelines Page.

  2. Under "Standard Buttons for Use in Table Rows and Other User Interface Elements" Copy the ContactAdd button(I save it as ContactAdd.png here). Add it to your project.

  3. In the cellForRowAtIndexPath:(NSIndexPath *)indexPath method add:

    UIImage *image = [UIImage imageNamed:@"ContactAdd.png"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    //You can also Use:
    //UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
    CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
    //match the button's size with the image size
    button.frame = frame;
    [button setBackgroundImage:image forState:UIControlStateNormal];
    // set the button's target to this table view controller so you can open the next view
    [button addTarget:self action:@selector(yourFunctionToNextView:) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor clearColor];
    cell.accessoryView = button;