0

I created a custom button as shown in below:

-(void)addYellowBtn{
    UIButton *customButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
   [customButton setBackgroundImage:[UIImage imageNamed: @"yellow3.jpg"]forState:UIControlStateNormal];
     //sets background image for highlighted state
    [customButton setBackgroundImage:[UIImage imageNamed: @"yellow5.jpg"] forState:UIControlStateHighlighted];
    [customButton setFrame:CGRectMake(60, 100, 60, 60)];
    [customButton setTitle:@"" forState:UIControlStateNormal];

        CALayer *btnLayer = [customButton layer];
        [btnLayer setMasksToBounds:YES];
        [btnLayer setCornerRadius:12.0f];
    [self.view addSubview:customButton];
    [customButton addTarget:self action:(btnclick1:) forControlEvents:UIControlStateNormal];
    }

when i click this button, next view will have to push.To do this,how can i write codings?

anu l
  • 41
  • 6
  • Your question is not clear, do you want to show another ViewController? – Axel Guilmin Oct 23 '14 at 11:39
  • possible duplicate of [iOS: present view controller programmaticallly](http://stackoverflow.com/questions/16152746/ios-present-view-controller-programmaticallly) – Axel Guilmin Oct 23 '14 at 11:45

1 Answers1

0

Change this:

   [customButton addTarget:self action:(btnclick1:) forControlEvents:UIControlStateNormal];

to this

   [customButton addTarget:self action:(btnclick1:) forControlEvents: UIControlEventTouchUpInside];

UIControlStateNormal is not a touch event.

latenitecoder
  • 746
  • 7
  • 13
  • In fact there is a few errors here. This is my snippet for buttons. [<#Button Name#> addTarget:self action:@selector(<#Method Name#>:) forControlEvents:UIControlEventTouchUpInside]; - you need the @selector as well – latenitecoder Oct 23 '14 at 21:18