2017-06-13 53 views
-1

UILabel無法顯示其所有字母。 我的應用程序就像now my appUILabel無法顯示其所有字母

PhotoController(就是這個頁面)是

import Foundation 
import MobileCoreServices 
import UIKit 
class PhotoController:UIViewController,UINavigationControllerDelegate,UIImagePickerControllerDelegate{ 

    @IBOutlet weak var label: UILabel! 
    @IBOutlet weak var myImageView: UIImageView! 
    private var imagePicker:UIImagePickerController! 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     label.text = "Tap the PhotoSelect or Camera to upload a picture" 
     //myImageUploadRequest() 


    } 

所以,

label.text = "Tap the PhotoSelect or Camera to upload a picture" 

所有字母在我的應用程序沒有顯示。

我應該怎麼做才能解決這個問題?

+0

label.numberOfLines = 0;默認情況下,UILabel將只有1行。 – Developer

+0

給number0fLines = 0 –

+0

看到這個https://stackoverflow.com/questions/446405/adjust-uilabel-height-depending-on-the-text –

回答

0
label.numberOfLines = 0 

要麼讓您的標籤多行或

label.adjustsFontSizeToFitWidth = true 

label.minimumScaleFactor = 0.5 
+0

不需要'numberOfLines' –

+0

@安布: - 我知道。仔細閱讀我的答案,我已經使用了字或 – Developer

1
label.numberOfLines = 0 

這就是所有你需要:)

編輯:

設置斷線模式標籤將幫助您進一步提高O/P

label.lineBreakMode = .byWordWrapping //choose whichever matches ur requirement 
+1

如果你的標籤寬度和高度較低,它會工作 –

+0

@ anbu-karthik :UILabels具有固有尺寸。因此,除非他已經對UILabel應用高度約束(我希望他沒有),否則將lineNumber設置爲0將使文本增長多於一行,並且由於內在大小標籤也會增長如果您正在使用'minimumScaleFactor',那麼:) –

0

從故事板

  1. 限制條件:

得到具有關係>=

  • 屬性
  • 組恆定標籤高度行數= 0