-2

I have created a button

@property (nonatomic, retain) UIButton *sendBtn;
@property (nonatomic, retain) UIButton * send;

//here is the code for button

CGRect buttonFrame = CGRectMake(270, 0, 60, 45); 
send = [[UIButton alloc] initWithFrame: buttonFrame];
[send setTitle: @"send" forState: UIControlStateNormal]; 
[send addTarget:self action:@selector(sendMsgAction:) forControlEvents:UIControlEventTouchUpInside]; 
[send setTitleColor: [UIColor redColor] forState: UIControlStateNormal]; 
[self addSubview:send];
self.otherBtn = send; self.sendBtn = send;

When i run it using developer profile it works correct But while using adhoc build it don't respond.

NOTE: it works fine in iphone4s,ipad2,iphone5 with adhoc and developer both but not working in iphone5s using adhoc build,while using developer work fine

9to5ios
  • 5,319
  • 2
  • 37
  • 65
  • check this http://stackoverflow.com/questions/1378765/how-do-i-create-a-basic-uibutton-programmatically – Mateusz Dec 04 '14 at 11:09
  • no button is correct,it might be some architecture issue of IOS version issue or might be developer or adhoc build issue causes such...is anyone face such striange behaviour?? – 9to5ios Dec 04 '14 at 11:15
  • NOTE: down voters please comment reason to down vote! – 9to5ios Dec 04 '14 at 11:19
  • instead of `send = [[UIButton alloc] initWithFrame: buttonFrame];` just say `send.frame = buttonFrame`. It will work – Fahim Parkar Dec 04 '14 at 11:31

1 Answers1

1

Point 1 : Never use reserve keywords. SEND should be sendButton or something else.

Point 2 : As I see you have @property (nonatomic, retain) UIButton * send; means you are connecting the button with IB.

As you already have button in IB, don't define it again in code. So I would say, instead of

send = [[UIButton alloc] initWithFrame: buttonFrame];

use it as

send.frame = buttonFrame;

Hope this will solve your problem...

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276