使用带参数的Selector()

时间:2015-09-29 09:09:51

标签: ios swift

如何将参数传递给函数switchCard

let singleTap1 = UITapGestureRecognizer(target: self, action: "switchCard:")

这是功能:

func switchCard(card: Int, withCard: Int) {
    print(card)
}

3 个答案:

答案 0 :(得分:2)

捕获轻击手势的功能应该是这样的:

<?php while ( $post_tabs->have_posts() ) : $post_tabs->the_post(); ?>
        <div id="tabs-<?php the_ID(); ?>">
            <?php the_content();
if (the_ID()==2) {

    echo
    '<div id="tabs-2">

                <div class="row">
                <div class="col-md-3">
                    <img src="img/about_multi.gif" alt="">
                    <h4>We Are Multi-Disciplinary</h4>
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic consequatur voluptatum illum commodi, possimus culpa incidunt vero repudiandae neque quas, rerum quis, consequuntur illo molestiae necessitatibus ea explicabo architecto impedit!</p>
                </div>';

}  ?>
        </div>

答案 1 :(得分:0)

您可以在点击的视图中使用标记:

SEL _selector = NSSelectorFromString([[arrEffects objectAtIndex:1] valueForKey:@"method"]);
self.mainImageView.image = [self.mainImage performSelector:_selector];

答案 2 :(得分:0)

检查以下代码及其工作原理:

func switchCard(card: Int, withCard card1: Int) {
    print(card)
}
let singleTap1 = UITapGestureRecognizer(target: self, action: "switchCard:withCard:")