CyberK
CyberK

Reputation: 1578

Custom UIButton not showing on device

I have a custom UIButton like this:

_facebookButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_facebookButton addTarget:self
                    action:@selector(buttonFacebookPressed:)
          forControlEvents:UIControlEventTouchDown];

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    [_facebookButton setBackgroundImage:[UIImage imageNamed:@"facebookInactive"] forState:UIControlStateNormal];
} else {
    [_facebookButton setBackgroundImage:[UIImage imageNamed:@"facebookInactive"] forState:UIControlStateNormal];
}

_facebookButton.frame = CGRectMake(0.0, 0.0, 33.0, 33.0);
_facebookButton.center = CGPointMake(60, 48);

_facebookButton.alpha = 0;
[_subView addSubview:_facebookButton];

It is in a UITableViewCell and on the simulator it looks OK, but on the actual device it is gone. I've searched the internet and they are always talking about image names which are not correct. I use the xcasset and have an image set named: facebookInactive.

enter image description here

Why is the button not showing up on the device?

Thanks in advance!

Upvotes: 0

Views: 274

Answers (3)

Haresh Ghatala
Haresh Ghatala

Reputation: 2006

you can goto your project in Project Navigator then
select your Project -> Build Phases -> Copy Bundle resourses and check that their is ".xcasset" avilable.

if No then click on "+" icon & add ".xcasset"

Now build & Run.

Upvotes: 0

Arun Kumar
Arun Kumar

Reputation: 798

You need to remove the statement

_facebookButton.alpha = 0;

or replace it with

_facebookButton.alpha = 1.0;

Upvotes: 0

Rushik Thumar
Rushik Thumar

Reputation: 106

Are you sure about that, ios Setting -> Facebook -> Sign in Process is completely registered ?

this may helpful to you.

Thanks & Regards, Rushik Thumar.

Upvotes: 1

Related Questions