2
我想創建一個顯示標題,子標題,嵌入圖像和常規文本(與維基百科樣式頁面有點類似)的顯示。我有我的標題,小標題,圖像和常規文字全部用字符串。我知道一個AttributedString是實現我想要的格式的最佳方式。我無法弄清楚的是如何從我預先存在的字符串中創建AttributedString。無法將NSString傳入NSMutableAttributedString?
displayText = [[NSMutableAttributedString alloc] initWithAttributedString:@"%@ \n %d - %@", self.currentInstance.name, self.currentInstance.number, self.currentInstance.image];
textView.attributedText = displayText;
我是新來的,所以我確定這是基本的東西我做錯了。我感謝任何幫助。
什麼錯誤,你好嗎?它看起來像你 – Abizern
你應該使用initWithString:not initWithAttributedString:因爲你傳入的是NSStrings。 – rdelmar
我得到的錯誤是「不兼容的指針類型發送'NSString *'到類型'NSAttributedString *'「的參數和」方法太多的參數d電話,預計1,有4「。 – Isaac