2016-04-02 11 views
2

Bir uygulama geliştirmeyi yeni bitirdim ve telefonuma yüklemeye karar verdim. Ardından, masa görünümlerimin telefonumda farklı olduğunu gördüm!Tablo görünümü hücrelerim neden telefonumda bu kadar büyük, ancak simülatörde değil?

Bu, görülmesi gereken şeydir. (Simülatörü)

enter image description here

Bu benim gördün şudur: (My Phone)

enter image description here

Gördüğünüz gibi, üzerinde "artık" benim telefon bakmak tablo görünümünde hücreleri benim Telefon, ama simülatörde normal görünüyor. Bunun neden olduğunu anlamıyorum. Nedenini söyler misin?

Telefonum, iOS 8.1.2 çalıştıran bir iPhone 6s Plus sürümüdür. Benim Simülatörü, bu yeniden film şeridine bir tablo görünümü denetleyicisi ekleyin ve prototip hücrede bu şeyleri koymak için

iOS 9.3 çalıştıran iPhone 6s Plus:

enter image description here enter image description here

nerede siyah sınır bir görüntü görüntüsüdür.

Ve sonra, bildiğiniz gibi, tablo görünümünde yaptığım gibi bazı hücreleri koyun. https://github.com//Sweeper777/ColorBible

indirme Xcode: Eğer yineleyemiyorsa

class ColorSchemeController: UITableViewController { 
    var color: UIColor! 

    override func viewDidLoad() { 
     super.viewDidLoad() 
    } 

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
     return 5 
    } 

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     switch section { 
     case 0...2: 
      return 3 
     case 3: 
      var h: CGFloat = 0 
      color.getHue(&h, saturation: nil, brightness: nil, alpha: nil) 
      if h == 0 { 
       return 3 
      } 
      return 5 
     case 4: 
      return 2 
     default: 
      return 0 
     } 
    } 

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) 
     let imageView = cell.viewWithTag(1)! as! UIImageView 
     let label = cell.viewWithTag(2)! as! UILabel 

     func setColor(color: UIColor) { 
      imageView.backgroundColor = color 
      label.text = color.hexDescription() 
     } 

     switch indexPath.section { 
     case 0: 
      switch indexPath.row { 
      case 0: 
       setColor(self.color) 
      case 1: 
       setColor(self.color.rotateHueByDegrees(120)) 
      case 2: 
       setColor(self.color.rotateHueByDegrees(-120)) 
      default: 
       assert(false) 
      } 
     case 1: 
      switch indexPath.row { 
      case 0: 
       setColor(self.color) 
      case 1: 
       setColor(self.color.rotateHueByDegrees(150)) 
      case 2: 
       setColor(self.color.rotateHueByDegrees(-150)) 
      default: 
       assert(false) 
      } 
     case 2: 
      switch indexPath.row { 
      case 0: 
       setColor(self.color) 
      case 1: 
       setColor(self.color.rotateHueByDegrees(30)) 
      case 2: 
       setColor(self.color.rotateHueByDegrees(-30)) 
      default: 
       assert(false) 
      } 
     case 3: 
      switch indexPath.row { 
      case 0: 
       setColor(self.color) 
      case 1: 
       var h: CGFloat = 0 
       color.getHue(&h, saturation: nil, brightness: nil, alpha: nil) 

       if h == 0 { 
        var v: CGFloat = 0 
        self.color.getHue(nil, saturation: nil, brightness: &v, alpha: nil) 
        if v <= 0.1 { 
         setColor(self.color.incrementValueBy(0.1)) 
        } else { 
         setColor(self.color.incrementValueBy(-0.1)) 
        } 
        break 
       } 

       var s: CGFloat = 0 
       self.color.getHue(nil, saturation: &s, brightness: nil, alpha: nil) 
       if s <= 0.1 { 
        setColor(self.color.incrementSaturationBy(0.1)) 
       } else { 
        setColor(self.color.incrementSaturationBy(-0.1)) 
       } 
      case 2: 
       var h: CGFloat = 0 
       color.getHue(&h, saturation: nil, brightness: nil, alpha: nil) 

       if h == 0 { 
        var v: CGFloat = 0 
        self.color.getHue(nil, saturation: nil, brightness: &v, alpha: nil) 
        if v >= 0.9 { 
         setColor(self.color.incrementValueBy(-0.2)) 
        } else { 
         setColor(self.color.incrementValueBy(0.2)) 
        } 
        break 
       } 

       var s: CGFloat = 0 
       self.color.getHue(nil, saturation: &s, brightness: nil, alpha: nil) 
       if s >= 0.9 { 
        setColor(self.color.incrementSaturationBy(-0.2)) 
       } else { 
        setColor(self.color.incrementSaturationBy(0.2)) 
       } 
      case 3: 
       var v: CGFloat = 0 
       self.color.getHue(nil, saturation: nil, brightness: &v, alpha: nil) 
       if v <= 0.1 { 
        setColor(self.color.incrementValueBy(0.1)) 
       } else { 
        setColor(self.color.incrementValueBy(-0.1)) 
       } 
      case 4: 
       var v: CGFloat = 0 
       self.color.getHue(nil, saturation: nil, brightness: &v, alpha: nil) 
       if v >= 0.9 { 
        setColor(self.color.incrementValueBy(-0.2)) 
       } else { 
        setColor(self.color.incrementValueBy(0.2)) 
       } 
      default: 
       assert(false) 
      } 
     case 4: 
      switch indexPath.row { 
      case 0: 
       setColor(self.color) 
      case 1: 
       setColor(self.color.rotateHueByDegrees(180)) 
      default: 
       assert(false) 
      } 
     default: 
      assert(false) 
     } 

     return cell 
    } 

    override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 
     switch section { 
     case 0: 
      return "Triadic" 
     case 1: 
      return "Split Complements" 
     case 2: 
      return "Analogous" 
     case 3: 
      return "Monochromatic" 
     case 4: 
      return "Complements" 
     default: 
      return nil 
     } 
    } 
} 

, burada github link: Burada


İhtiyacınız ihtimale tablo görünümünde kodudur proje ve telefonunuzda çalıştırın.

cevap

2

Aynı efekti simülatörde çoğaltabilirim 8.1.
tableView'un rowHeight öğesinin -1 (UITableViewAutomaticDimension) olarak ayarlandığını fark ettim, bu nedenle sorunun dinamik boyutlandırma ile bir ilgisi var (neden, iOS 8'de farklı bir davranışa benzediğinden emin değil).

override func viewDidLoad() { 
    super.viewDidLoad() 
    self.tableView.rowHeight = 44; 
} 
+0

Çok teşekkür ederim! İşe yarıyor! – Sweeper

1

"100.0" Eğer tahmin nedir hücreyi

tableView.estimatedRowHeight = 100.0 
tableView.rowHeight = UITableViewAutomaticDimension 

dönmeden önce böyle bir şey deneyin:

Bu (dinamik boyutlandırma gerekmez varsayarak) düzeltmek gibi görünüyor Sıra yüksekliğiniz.

İlgili konular