类型的值' [SKNode]'没有会员'名称'

时间:2018-04-28 20:38:06

标签: swift

我的代码有问题。请帮我5号线!错误说:

  

类型' [SKNode]的价值'没有会员'名称'

这是我收到错误的函数:

 override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

    for touch: AnyObject in touches{
        let pointOfTouch = touch.location(in: self)
        let nodeITapped = self.nodes(at: pointOfTouch)

        if nodeITapped.name == "startButton"{

            let sceneToMoveTo = GameScene(size: self.size)
            sceneToMoveTo.scaleMode = self.scaleMode
            let myTransition = SKTransition.fade(withDuration: 0.5)
            self.view!.presentScene(sceneToMoveTo, transition: myTransition)

        }

我在使用if nodeITapped.name == "startButton"

的行上收到错误

2 个答案:

答案 0 :(得分:0)

return返回一个节点数组,因此你应该循环检查每个节点的数组。此外,在找到该节点后,您应该从您的函数中override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { for touch in touches { let pointOfTouch = touch.location(in: self) for nodeITapped in self.nodes(at: pointOfTouch) { if nodeITapped.name == "startButton" { let sceneToMoveTo = GameScene(size: self.size) sceneToMoveTo.scaleMode = self.scaleMode let myTransition = SKTransition.fade(withDuration: 0.5) self.view!.presentScene(sceneToMoveTo, transition: myTransition) // found the one I was looking for, so don't continue return }

<div class="horiZontalScroll">
    <table class="table highlight makeGapTable buyerTable setHeightThTd scrollTableRow">
        <thead>
            <tr class="auctionTable prodActName">
                <th class="active_purchase"><strong>Product</strong> <small>Auction</small></th>
                <th class="active_purchase"><strong>Volume</strong><small>ID number</small></th>
                <th class="active_purchase"><strong>Starting Price</strong> <small>Minimum Price</small></th>
                <th class="active_purchase"><strong>Bids</strong> <small>Current Price</small> </th>
                <!--<th><strong>Bids/Bidders</strong></th>-->
                <th class="active_purchase"><strong>Duration</strong></th>
                <th class="active_purchase"><strong>Action</strong></th>
            </tr>
        </thead>
        <tbody id="active_auctions" class="mCustomScrollbar _mCS_3 mCS_no_scrollbar">
            <div id="mCSB_3" class="mCustomScrollBox mCS-light mCSB_vertical mCSB_inside" tabindex="0">
                <div id="mCSB_3_container" class="mCSB_container mCS_y_hidden mCS_no_scrollbar_y" style="position:relative; top:0; left:0;" dir="ltr">
                    <tr class="auctionTable rowHref prodActName" style="cursor: pointer;" id="auctionlistrow621" href="/buyer/auction/auctiondetail/id/621">

                        <td class="active_purchase">
                            <strong>360A iodide</strong>

                            <small style="font-size: 75%;">Dutch Auction</small>
                        </td>

                        <td class="active_purchase"> 12.000 fl oz <small style="font-size: 75%;">ID 621</small>
                        </td>

                        <td class="active_purchase"> 10.000 EUR/fl oz
                            <small>100 EUR/fl oz</small>
                        </td>

                        <td class="active_purchase">
                            <small class="">9.600 EUR/fl oz</small>

                        </td>

                        <td class="active_purchase">

                            <span class="duration_left" data-id="621" data-bind="11d 20h 8m <br></span>">11d 20h 8m
                            <br>
                            </span> <small>10.05.2018 22:10:54</small>
                        </td>

                        <td class="active_purchase actionIcons">

                            <a title="Place Bid" href="javascript:void(0)" id="dutch_popupBtn" data-bind="621"><i class="fa fa-gavel" noredirect="1"></i></a>
                            <i title="Remove Auction" class="fa fa-remove no auctionDeleteBtnClass" data-bind="621" noredirect="1"></i>
                            <a title="Contact Seller" href="javascript:void(0)" id="requestQues" data-params="{&quot;userid&quot;:&quot;343&quot;,&quot;name&quot;:&quot;Beta Zero&quot;,&quot;company&quot;:&quot;Clavax Zer0&quot;,&quot;membership&quot;:&quot;4&quot;,&quot;companyrevenue&quot;:&quot;&quot;}" data-auction="621"><i class="fa fa-envelope no" noredirect="1"></i></a>
                            <a title="Click to learn more" href="javascript:void(0);" data="dutch" class="tour_popupBtn" noredirect="1"><i class="fa fa-exclamation-circle" noredirect="1"></i></a>
                        </td>
                    </tr>

                    <tr class="auctionTable rowHref prodActName" style="cursor: pointer;" id="auctionlistrow615" href="/buyer/auction/auctiondetail/id/615">

                        <td class="active_purchase">
                            <strong>360A iodide</strong>

                            <small style="font-size: 75%;">Dutch Auction</small>
                        </td>

                        <td class="active_purchase"> 12.000 Liter <small style="font-size: 75%;">ID 615</small>
                        </td>

                        <td class="active_purchase"> 5.000 USD/Liter
                            <small>1.000 USD/Liter</small>
                        </td>

                        <td class="active_purchase">
                            <small class="">4.900 USD/Liter</small>

                        </td>

                        <td class="active_purchase">

                            <span class="duration_left" data-id="615" data-bind="4d 18h 40m <br></span>">4d 18h 40m
                            <br>
                            </span> <small>03.05.2018 20:42:57</small>
                        </td>

                        <td class="active_purchase actionIcons">

                            <a title="Place Bid" href="javascript:void(0)" id="dutch_popupBtn" data-bind="615"><i class="fa fa-gavel" noredirect="1"></i></a>
                            <i title="Remove Auction" class="fa fa-remove no auctionDeleteBtnClass" data-bind="615" noredirect="1"></i>
                            <a title="Contact Seller" href="javascript:void(0)" id="requestQues" data-params="{&quot;userid&quot;:&quot;343&quot;,&quot;name&quot;:&quot;Beta Zero&quot;,&quot;company&quot;:&quot;Clavax Zer0&quot;,&quot;membership&quot;:&quot;4&quot;,&quot;companyrevenue&quot;:&quot;&quot;}" data-auction="615"><i class="fa fa-envelope no" noredirect="1"></i></a>
                            <a title="Click to learn more" href="javascript:void(0);" data="dutch" class="tour_popupBtn" noredirect="1"><i class="fa fa-exclamation-circle" noredirect="1"></i></a>
                        </td>
                    </tr>

                </div>
                <div id="mCSB_3_scrollbar_vertical" class="mCSB_scrollTools mCSB_3_scrollbar mCS-light mCSB_scrollTools_vertical" style="display: none;">
                    <div class="mCSB_draggerContainer">
                        <div id="mCSB_3_dragger_vertical" class="mCSB_dragger" style="position: absolute; min-height: 30px; height: 0px; top: 0px;" oncontextmenu="return false;">
                            <div class="mCSB_dragger_bar" style="line-height: 30px;"></div>
                        </div>
                        <div class="mCSB_draggerRail"></div>
                    </div>
                </div>
            </div>
        </tbody>
    </table>
</div>

答案 1 :(得分:0)

  

因为您收到此错误:类型的值&#39; [SKNode]&#39;没有会员&#39;名称&#39;

     
    

我认为nodeITapped是一个节点数组,所以像

一样使用   
for nodeITapped in self.nodes(at: pointOfTouch) {

    if nodeITapped.name == "startButton"{
  

     

可以像这样尝试循环:

ItemsSource="{Binding QuadStash, Source={StaticResource Settings}, Mode=TwoWay}"