未调用UIButton操作

时间:2012-09-03 07:00:47

标签: iphone objective-c ios uibutton

我有一个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];
                }
       }];
}

1 个答案:

答案 0 :(得分:5)

问题是UIView正在掩盖它下方的按钮。因为视图是透明的,所以我没有意识到它覆盖了任何东西。