2017-02-02 140 views
0

面前我這裏有一個奇怪的問題:網格顯示在UITableViewCell中

Screenshot

我把UITableView的分離粉紅色。正如你所看到的,在我的單元格的中間和末尾顯示了一些行,但是有一個偏移量。當我滾動時它不會移動,所以我將它稱爲一個顯示在我的單元格前面的網格。 我在這裏面臨的大問題是,它只顯示在iPhone7模擬器(IOS 10)和更少(7s不顯示此網格)。

你們對於爲什麼以及如何解決這個問題有什麼想法嗎?

如果你需要一些代碼,告訴我,我會編輯我的文章。

謝謝!

這裏是廈門國際銀行:

<!--Articles--> 
     <scene sceneID="j0Y-qF-3lq"> 
      <objects> 
       <viewController id="6B8-Tk-xPz" userLabel="Articles" customClass="HeadController" customModule="E_R" sceneMemberID="viewController"> 
        <layoutGuides> 
         <viewControllerLayoutGuide type="top" id="H0o-ZU-FUz"/> 
         <viewControllerLayoutGuide type="bottom" id="DVT-NA-hNg"/> 
        </layoutGuides> 
        <view key="view" contentMode="scaleToFill" id="Qib-nc-8lK" customClass="UITableView"> 
         <rect key="frame" x="0.0" y="64" width="375" height="554"/> 
         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/> 
         <subviews> 
          <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="90" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="oLy-kw-Uc2"> 
           <rect key="frame" x="0.0" y="0.0" width="375" height="554"/> 
           <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 
           <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 
           <color key="separatorColor" red="1" green="0.0" blue="0.95666110710516339" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 
           <prototypes> 
            <tableViewCell opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ArticleTableViewCell" rowHeight="90" id="owe-aQ-qV4" customClass="ArticleTableViewCell" customModule="E_R"> 
             <rect key="frame" x="0.0" y="28" width="375" height="90"/> 
             <autoresizingMask key="autoresizingMask"/> 
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="owe-aQ-qV4" id="k3G-5w-mGo"> 
              <rect key="frame" x="0.0" y="0.0" width="375" height="89"/> 
              <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/> 
              <subviews> 
               <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="wordWrap" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VV9-uR-YRk"> 
                <rect key="frame" x="7" y="0.0" width="271" height="54"/> 
                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> 
                <fontDescription key="fontDescription" name=".SFNSText" family=".SF NS Text" pointSize="13"/> 
                <nil key="highlightedColor"/> 
               </label> 
               <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T9Y-oH-4IA"> 
                <rect key="frame" x="7" y="57" width="268" height="34"/> 
                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES"/> 
                <fontDescription key="fontDescription" name=".SFNSText" family=".SF NS Text" pointSize="11"/> 
                <nil key="highlightedColor"/> 
               </label> 
               <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Z8M-gG-zVc"> 
                <rect key="frame" x="283" y="0.0" width="88" height="88"/> 
                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/> 
               </imageView> 
              </subviews> 
             </tableViewCellContentView> 
             <accessibility key="accessibilityConfiguration" identifier="ArticleTableViewCell"> 
              <bool key="isElement" value="NO"/> 
             </accessibility> 
             <gestureRecognizers/> 
             <connections> 
              <outlet property="previewImage" destination="Z8M-gG-zVc" id="J2R-HU-hYb"/> 
              <outlet property="subTitleLabel" destination="T9Y-oH-4IA" id="RuM-IV-kza"/> 
              <outlet property="titleLabel" destination="VV9-uR-YRk" id="9v5-6F-3lA"/> 
              <segue destination="BTc-SH-fsG" kind="show" identifier="ShowDetail" id="SZH-pm-QeE"/> 
             </connections> 
            </tableViewCell> 
           </prototypes> 
          </tableView> 
         </subviews> 
         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 
        </view> 
        <extendedEdge key="edgesForExtendedLayout"/> 
        <navigationItem key="navigationItem" id="mnh-mw-Uiz"> 
         <segmentedControl key="titleView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="fill" contentVerticalAlignment="fill" segmentControlStyle="bar" selectedSegmentIndex="0" id="ghy-sl-9Yp"> 
          <rect key="frame" x="92" y="7" width="191" height="30"/> 
          <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> 
          <segments> 
           <segment title="A la une"/> 
           <segment title="Tous"/> 
          </segments> 
          <connections> 
           <action selector="SwitchList:" destination="6B8-Tk-xPz" eventType="valueChanged" id="a4M-GY-kSb"/> 
          </connections> 
         </segmentedControl> 
        </navigationItem> 
        <connections> 
         <outlet property="ArticlesList" destination="oLy-kw-Uc2" id="qXj-r7-lJg"/> 
         <outlet property="SegmentedArticles" destination="ghy-sl-9Yp" id="oTe-Vh-Kns"/> 
        </connections> 
       </viewController> 
       <placeholder placeholderIdentifier="IBFirstResponder" id="l57-G8-yDO" userLabel="First Responder" sceneMemberID="firstResponder"/> 
      </objects> 
      <point key="canvasLocation" x="237.59999999999999" y="425.93703148425789"/> 
     </scene> 

而且圖像單元格原型:

Image cell prototype

+0

顯示您的'prototype-cell'圖像。 –

+0

在這裏發佈你的xib – iProgrammer

+0

看我的編輯。這個可以嗎 ? –

回答

0

好的我有答案。很簡單 !我有一個TableViewController,其中包括一個TableView。問題是我在TableViewController中包含了另一個TableView!這就是爲什麼我在我的第二個TableView前面有一種「網格」。

+0

我如何瞭解故事板中視圖的層次結構。這些愚蠢的錯誤無法在這個社區得到解決。您應該完全調試,然後尋求幫助。無論如何,如果你有解決方案,我會很高興快樂編碼:) – iProgrammer

0

我覺得你的表視圖的rowHeight是老丁的默認值。在viewDidLoad方法 試試這個代碼:

override func viewDidLoad() { 
    tableView.estimatedRowHeight = 150.0 
    tableView.rowHeight = UITableViewAutomaticDimension 
    tableView.tableFooterView = UIView() 
} 

而且隱藏的tableView默認分隔符(如果已經添加它作爲一個自定義的線,否則沒有必要)

Like this

希望這將解決這個問題。

UPDATE

如果你不知道如何添加布局constarints和您的tableView只有一種類型的細胞,那麼你可以設置rowHeight的故事板中也。選擇您的viewController中的tableView並轉到屬性檢查

添加截圖:

設置所需rowHeight的這裏。它可能會解決您的問題。

Row height

+0

Nop它不起作用...而且,佈局不再好。 –

+0

您需要設置約束。它肯定會解決你的問題 – iProgrammer

+0

我沒有一個。你的意思是對錶格視圖或單元格的約束? (我是IOS新手,很快) –