Reputation: 2711
I have a UIButton that I'm adding dynamically using content parsed from an XML file (it's also getting cached).
The first time I run the app, the button's action isn't getting called - but its image and everything else loads just fine. The second time I run the app, the button works.
Any clue on why the button's action doesn't get called the first time I run the app?
- (void)fetchHeader
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
// Initiate the request...
channel1 = [[FeedStore sharedStore] fetchFeaturedHeaderWithCompletion:
^(RSSChannel *obj, NSError *err) {
if(!err) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
// Set our channel to the merged one
channel1 = obj;
RSSItem *d = [[channel1 items] objectAtIndex:0];
RSSItem *c = [[channel1 items] objectAtIndex:1];
NSString *param = [d photoURL]; // the URL from the XML
NSString *param1 = [c photoURL]; // the URL from the XML
featured1 = [[UIButton alloc] init];
[featured1 addTarget:self action:@selector(featuredButtonPress:) forControlEvents:UIControlEventTouchUpInside];
[featured1 setFrame:CGRectMake(18, 20, 123, 69)];
[featured1 setImageWithURL:[NSURL URLWithString:param] placeholderImage:[UIImage imageNamed:@"featuredheaderbg.png"]];
featured1.tag = 1;
[[self view] addSubview:featured1];
}
}];
}
Upvotes: 0
Views: 1845
Reputation: 2711
The issue was that a UIView was covering up the button below it. Because the view was transparent, I didn't realize it was covering anything up.
Upvotes: 6