Re: UIButton not visible
Re: UIButton not visible
- Subject: Re: UIButton not visible
- From: Koen van der Drift <email@hidden>
- Date: Wed, 26 Jun 2013 16:24:39 -0400
Ok, I solved it. I had to change the order of views that I create, and put the infobutton to the end.
- Koen.
On Jun 26, 2013, at 3:55 PM, Koen van der Drift <email@hidden> wrote:
> I'd like to have a small info-style button in the lower left corner of my screen, and added this code (no xib):
>
> - (void)setupInfoButton
> {
> UIButton *infoButton = [UIButton buttonWithType: UIButtonTypeInfoDark];
>
> [infoButton addTarget: self
> action: @selector(showInfo:)
> forControlEvents: UIControlEventTouchDown];
>
> infoButton.showsTouchWhenHighlighted = YES;
>
> [self.view addSubview:infoButton];
> [self.view bringSubviewToFront:infoButton];
>
> infoButton.translatesAutoresizingMaskIntoConstraints = NO;
>
> NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(infoButton);
>
> [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat: @"H:|-15-[infoButton]"
> options: 0
> metrics: nil
> views: viewsDictionary]];
>
> [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat: @"V:[infoButton]-15-|"
> options: 0
> metrics: nil
> views: viewsDictionary]];
> }
>
>
> Alas, it is not showing up. I played around with the values of the constraints to move it more to the middle, but still it is not there. By using bringSubviewToFront: I force it to be the front most view, so it is no masked by other views.
>
> Any one sees what I am missing?
>
> Thanks,
>
> - Koen.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden