2014-10-03 49 views
1

我想澄清一下你們的問題。修復了由於缺少Rect標記而導致的UITableViewCell底部邊距問題

最近我只是升級我的Xcode到最新的Xcode 6.0.1(Maverick OS)並繼續我的項目由Xcode 5創建沒有問題。

直到我創造新的UITableViewCell,並把與固定的下緣幾個視圖控制器中的表現時。與固定的底部邊緣的視圖Y位置搞砸了, 但..它弄亂......這不是與發生現有的UITableViewCell是在Xcode 5上創建的。它具有固定底部邊距的View,但是錯誤沒有發生,當我調整UITableViewCell的大小時,它調整位置就好了。

繼續我的調試,我嘗試重新創建現有的UITableViewCell並得到相同的錯誤。經過多次測試後,我決定通過在文本編輯器中打開XIB來比較視圖,並發現導致錯誤的一點區別。

您可以比較2 UITableViewCell波紋管之間的結果。左圖是使用Xcode 5上創建的現有UITableViewCell,以及Xcode 6上創建的右圖。「text 2」標籤Y位置已經混亂並超出了單元格高度。

如果您檢查Xcode IB,所有設置都是相同的。但是,文本編輯器顯示更重要的是

created with Xcode 5 created with Xcode 6

現有的UITableViewCell(Xcode中5)

<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="WSPostCell" rowHeight="100" id="PdK-a2-c84" customClass="WSPostCell"> 
    <rect key="frame" x="0.0" y="0.0" width="320" height="100"/> 
    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> 
    <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="PdK-a2-c84" id="Y9d-Wv-BGf"> 
     <rect key="frame" x="0.0" y="0.0" width="320" height="99"/> 
     <autoresizingMask key="autoresizingMask"/> 
     <subviews> 
      <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text 1" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Vuu-pP-JOA"> 
       <rect key="frame" x="20" y="8" width="280" height="30"/> 
       <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> 
       <fontDescription key="fontDescription" type="system" pointSize="12"/> 
       <nil key="highlightedColor"/> 
      </label> 
      <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text 2" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="40X-YI-rMb"> 
       <rect key="frame" x="20" y="61" width="280" height="30"/> 
       <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> 
       <fontDescription key="fontDescription" type="system" pointSize="12"/> 
       <nil key="highlightedColor"/> 
      </label> 
     </subviews> 
    </tableViewCellContentView> 
    <point key="canvasLocation" x="127" y="120"/> 
</tableViewCell> 

新的UITableViewCell(Xcode6)

<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="100" id="aI1-wx-nYK"> 
    <rect key="frame" x="0.0" y="0.0" width="320" height="100"/> 
    <autoresizingMask key="autoresizingMask"/> 
    <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aI1-wx-nYK" id="dNV-Xk-dVs"> 
     <autoresizingMask key="autoresizingMask"/> 
     <subviews> 
      <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text 1" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="N8L-oO-ECr"> 
       <rect key="frame" x="8" y="8" width="280" height="30"/> 
       <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> 
       <fontDescription key="fontDescription" type="system" pointSize="12"/> 
       <nil key="highlightedColor"/> 
      </label> 
      <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text 2" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="IZV-oh-bet"> 
       <rect key="frame" x="8" y="61" width="280" height="30"/> 
       <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> 
       <fontDescription key="fontDescription" type="system" pointSize="12"/> 
       <nil key="highlightedColor"/> 
      </label> 
     </subviews> 
    </tableViewCellContentView> 
    <point key="canvasLocation" x="511" y="120"/> 
</tableViewCell> 

如果你仔細的看第二個XML丟失<rect>標記<tableViewCellContentView>標記後。

<rect key="frame" x="0.0" y="0.0" width="320" height="99"/> 

這是一個錯誤?或者我錯過了導致這個可怕錯誤的東西?我在File Inspector上禁用Auto Layout和Size classes。

+0

我有同樣的問題,我填寫了一個錯誤報告。它發生在XCode 6和XCode 6.1上。 – rFlex 2014-10-14 02:16:26

回答

0

我在Xcode6中有類似的問題。此外,我使用動態單元格,其內容不可見。 我嘗試過和沒有自動佈局和類的大小。

在故事板我有下:VC>查看>的TableView>自定義的小區(標識)>內容查看

我創造了非常簡單的項目 - 它裝載VC與TableView中喜歡這裏:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *cellIdentifier = @"DataCell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; 
cell.backgroundColor = [UIColor redColor]; 
return cell; } 

但我甚至不能改變單元格的背景......它是一團糟......我嘗試過使用標籤和標籤的其他方式,創建子類但沒有希望。我所有的網點都連接起來了,所有的標識符都被設置了,我猜這個單元格出現在tableview之外,並且它是由AutoLayout引起的...

目前我有一個黑客建議來解決這個問題 - 你可以導入一個故事板從你之前的項目中選擇適當的TableView。之後,所有的定製工作。 How to import storyboard.

然而,這不是一個好的做法,我希望有人會找到編碼解決方案,否則蘋果公司將解決這個問題。

相關問題