Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd UIImageView to custom UIButton class
    primarykey
    data
    text
    <p>I created a custom UIButton class and overwrote the init Method :</p> <pre><code>- (id)initWithFrame:(CGRect)frame title:(NSString *)titulo { self = [super initWithFrame:frame]; if (self) { // Initialization code setaDown = [UIImage imageNamed:@"setaDown"]; separator = [UIImage imageNamed:@"separatorLine"]; self = [UIButton buttonWithType:UIButtonTypeCustom]; [self setFrame:frame]; self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; self.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0); seta = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width-setaDown.size.width*2, frame.size.height/2, setaDown.size.width/1.2, setaDown.size.height/1.2)]; [seta setImage:setaDown]; [self addSubview:seta]; separatorLine = [[UIImageView alloc]initWithFrame:CGRectMake(5, frame.size.height-2, frame.size.width-10, separator.size.height)]; [separatorLine setImage:separator]; [self addSubview:separatorLine]; [self setTitle:titulo forState:UIControlStateNormal]; [self setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [self setTitleColor:[UIColor blackColor] forState:UIControlStateSelected]; self.backgroundColor = [UIColor whiteColor]; } return self; } </code></pre> <p>The problem is, the images doesnt show in the button, and i have a <code>exc_bad_access</code>, in the line :</p> <pre><code>seta = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width-setaDown.size.width*2, frame.size.height/2, setaDown.size.width/1.2, setaDown.size.height/1.2)]; </code></pre> <p>dont know exaclty why im getting this error, and how to solve it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload