我有一个 UIButton,我正在使用从 XML 文件解析的内容动态添加它(它也被缓存)。
我第一次运行应用程序时,按钮的操作没有被调用 - 但它的图像和其他一切都加载得很好。我第二次运行该应用程序时,该按钮有效。
关于为什么在我第一次运行应用程序时按钮的操作没有被调用的任何线索?
- (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];
}
}];
}