I am sure that I am losing sight of the obvious, because I have countless working buttons ... but ... for some reason this person is not cooperating ...
I added UIButton (Rounded Rect) to a subclass of UIView (DialogView), which is the view control of my view controller. This similarity is created almost entirely in IB. I connected the (IBAction)okButtonPressed:(id)sender button in IB before Touch Up Inside and created the corresponding method in DialogView. However, when I touch this button, this does not call the method. userInteractionEnabled true to view VC, DialogView and UIButton .
The thought, perhaps, initWithCoder was to do some frame manipulation or something that I added that successfully logs into the console.
- (id)initWithCoder:(NSCoder *)decoder { if (self = [super initWithCoder:decoder]) { NSLog(@"DialogView initWithCoder called"); } return self; }
In further research, I connected the IBOutlet button to the button, and then, if I try to change the Label header from the view controller, I noticed that it is very truncated. The default text β Press Me! β Set to IB is displayed in the order when the view is first drawn. But if I changed the text ...
self.DialogView.okButton.titleLabel.text = @"Not Working";
... it truncates to "N ..."
I do not know if this is connected. Maybe...
Does anyone see what I messed up here?
Edit (adding code related to showing UIButton ):
From the view controller:
self.DialogView = [[[NSBundle mainBundle] loadNibNamed:@"DialogView" owner:self options:nil] objectAtIndex:0];; self.DialogView.myVC = self; self.DialogView.backgroundColor = [UIColor clearColor]; self.DialogView.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2); self.DialogView.nameLabel.text = loan.fullName; self.DialogView.noteLabel.text = loan.summaryOfLoan; self.DialogView.amountLabel.text = [currencyFormatter stringFromNumber:loan.originalAmount]; self.DialogView.alpha = 0.0; [self.view addSubview:DialogView];
UILabels all display as expected. Like the UIButton problem. I see this, I just canβt interact with him!?!
DialogView Interface:
@class MyViewController; @interface DialogView : UIView { IBOutlet UILabel *nameLabel, *noteLabel, *amountLabel; IBOutlet UIImageView *arrowView; IBOutlet UIButton *okButton; MyViewController *myVC; } @property (nonatomic, retain) UILabel *nameLabel, *noteLabel, *amountLabel; @property (nonatomic, retain) UIImageView *arrowView; @property (nonatomic, assign) MyViewController *myVC; @property (nonatomic, retain) UIButton *okButton; - (IBAction)okButtonPressed:(id)sender; @end
And the DialogView implementation:
#import "DialogView.h" #import "MyViewController.h" @implementation DialogView @synthesize nameLabel, noteLabel, amountLabel, arrowView, okButton; @synthesize myVC; - (void)dealloc { [nameLabel release]; [noteLabel release]; [amountLabel release]; [arrowView release]; [okButton release]; [super dealloc]; } - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) {