对于多行按钮文字,我相信你添加" \ n"到字符串。但是,我在连接函数结果和newlinetext
时遇到了麻烦的setTitle:
HomeVC.getFriendCount("2",id:"friendid") + "\n newlinetext"
我需要帮助将我的功能结果与" \ n newlinetext"
联系起来答案 0 :(得分:1)
您没有指定错误,所以我不确定,但我打赌getFriendCount
会返回一个数字。
试试这个:
let count = HomeVC.getFriendCount("2",id:"friendid")
let title = "\(count)\n newlinetext"
答案 1 :(得分:0)
我已经遇到过这种情况。 (字符串+字符串)必定存在一些问题,因为它只是忽略了\ n,尽管我从未理解为什么会这样。您可以使用join函数修复它:
let stringsToJoin = [getFriendCount("2",id:"friendid"), "newlinetext"]
let nString = join("\n", stringsToJoin)
希望它有所帮助!
答案 2 :(得分:0)
您可以使用NSString的stringByAppendingString方法
$scope.modalOpen
答案 3 :(得分:0)
如果你的方法
HomeVC.getFriendCount("2",id:"friendid")
返回和可选的字符串,然后你需要在连接之前解包它。
尝试
HomeVC.getFriendCount("2",id:"friendid")! + "\n newlinetext"