I've been going through both the Developer Documentation on this and Googling for answers for an hour or two now, and I just can't seem to find out why this isn't working.
I have a custom class based off of UIAlertView...
The UITextField shows up just fine, but all I get for the UIButton is a rounded rectangle.
Upon further inspection, I found that changing the button type I initiate with to a UIButtonTypeCustom will properly display the title, but not the background.
So why isn't the button displaying the title when I change it to a RoundedRect type? Trying to make a rounded rect button in Interface Builder and giving it a title worked just fine; why doesn't it work programmatically? (It's easier to set the button up programmatically since it's being added to a UIAlertView.)
I have a custom class based off of UIAlertView...
Code:
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...
{
if (self = [super initWithTitle:@"Add Assignment" message:@" \n \n \n " delegate:(id)delegate cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil])
{
// New Assignment Name
addAssignmentName = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 27.0)];
addAssignmentName.borderStyle = UITextBorderStyleRoundedRect;
addAssignmentName.autocapitalizationType = UITextAutocapitalizationTypeWords;
addAssignmentName.autocorrectionType = UITextAutocorrectionTypeNo;
addAssignmentName.placeholder = @"New Assignment Name";
[self addSubview:addAssignmentName];
[addAssignmentName becomeFirstResponder];
[addAssignmentName release];
// New Assignment Class Name
addAssignmentClass = [[UIButton buttonWithType:UIButtonTypeRoundedRect] initWithFrame:CGRectMake(12.0, 90.0, 260.0, 37.0)];
[addAssignmentClass setTitle:@"Select Class" forState:UIControlStateNormal];
[addAssignmentClass setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
addAssignmentClass.backgroundColor = [UIColor clearColor];
addAssignmentClass.titleLabel.adjustsFontSizeToFitWidth = TRUE;
[addAssignmentClass addTarget:self action:@selector(selectClass:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:addAssignmentClass];
[self setTransform:CGAffineTransformMakeTranslation(0.0, 85.0)];
}
return self;
}
The UITextField shows up just fine, but all I get for the UIButton is a rounded rectangle.
Upon further inspection, I found that changing the button type I initiate with to a UIButtonTypeCustom will properly display the title, but not the background.
So why isn't the button displaying the title when I change it to a RoundedRect type? Trying to make a rounded rect button in Interface Builder and giving it a title worked just fine; why doesn't it work programmatically? (It's easier to set the button up programmatically since it's being added to a UIAlertView.)