2014-12-24 51 views
1

這聽起來是非常小的問題,但我堅持:(TSMessage - 額外的參數「形象」呼叫

我使用TSMessage在迅速「呼叫額外的參數‘形象’」得到錯誤是什麼?錯

func showActionNotification(title:String?, message:String?, viewcontroller:UIViewController, actionTitle:NSString, action:(()->Void)) -> Void { 
    var image:UIImage! = UIImage(named: "Sample.png") 
    TSMessage.showNotificationInViewController(viewcontroller, 
    title: title, subtitle: message, image: image, 
    type: TSMessageNotificationType.Message, 
    duration: TSMessageNotificationDuration.Automatic, 
    callback: nil, buttonTitle: actionTitle, buttonCallback: action, 
    atPosition: TSMessageNotificationPosition.Top, canBeDismissedByUser: true) 
} 

感謝

+0

你是如何得到它在Swift中工作的? –

+0

@ScottZhu我添加了橋接頭並在那裏導入了頭文件。 – iMemon

回答

2

我剛碰到這個相同的問題。 Xcode給出的錯誤與實際問題完全無關。它與image的論點無關。

事實證明,TSMessageNotificationDuration枚舉不會將屬性轉換爲NSTimeInterval。我嘗試以下,但它沒有工作:

TSMessageNotificationDuration.Automatic as NSTimeInterval 

Xcode的抱怨「TSMessageNotificationDuration」是無法轉換爲「NSTimeInterval」

所以不是,我看看是什麼枚舉相當於。就我而言,我使用的是TSMessageNotificationDuration.Endless,相當於-1。

所以我改變了我的代碼如下,其中的工作:

var endless:NSTimeInterval = -1 

TSMessage.showNotificationInViewController(viewController, 
    title: title, 
    subtitle: subtitle, 
    image:image, 
    type: TSMessageNotificationType.Message, 
    duration: endless, 
    callback: {() -> Void in }, 
    buttonTitle: "", 
    buttonCallback: {() -> Void in }, 
    atPosition: TSMessageNotificationPosition.Top, 
    canBeDismisedByUser: false) 

TSMessageNotificationDuration.Automatic枚舉等於0

我希望這有助於。

+1

你也可以明確地將原始值轉換爲'NSTimeInterval':'NSTimeInterval(TSMessageNotificationDuration.Automatic.rawValue)' – Koraktor

0

您傳遞標題和消息作爲自選項目 - 如果TSMessage(?目標三)不希望出現這種情況可能會導致問題的自選

+0

這不是問題,已經試過了。它也不能工作 – iMemon