如何添加从nib文件加载的自定义CalloutView [英] How to add a custom CalloutView loaded from nib file

查看:127
本文介绍了如何添加从nib文件加载的自定义CalloutView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为AnnotationView创建一个自定义的Callout视图。我见过这个答案,看起来是一个很好的解决方案(可行)。我正在尝试从nib文件加载UIView,并且出现UIView,但是他的按钮不起作用,不要被推。

I'm trying to make a custom Callout view for AnnotationView. I had seen this answer, and seems a good solution (it works). I'm trying to load a UIView from a nib file, and the UIView appears, but his buttons don't work, don't get pushed.

是否有做这个的方式?如何从nib文件加载UIView并使按钮工作?
或者也许有人帮我找到一个好的解决方案。

Is there a way of doing this?? How can I load the UIView from a nib file and get the buttons working?? Or maybe anyone help me finding a good solution.

谢谢

这是代码我' m使用:

Here's the code I'm using:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    if(selected)
    {
        //Add custom view to self...
        calloutView = [[[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil] objectAtIndex:0];
        [self addSubview:calloutView];
    }
    else
    {
        //Remove custom view...
        if (calloutView) {
            [calloutView removeFromSuperview];
        }
    }
}

提前致谢

推荐答案

我找到了解决问题的方法: gik-animated-callout

I found a solution for my problem: gik-animated-callout

这篇关于如何添加从nib文件加载的自定义CalloutView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆