2016-06-30 108 views
0

如何自定義通知作爲警報顯示時顯示的按鈕?讓我澄清我的意思:在創建了一些交互式通知操作並將它們放入要用於本地通知的類別中之後,所有操作都很好。但是,當通知顯示爲警報視圖時,我只能看到兩個按鈕:關閉選項。有沒有辦法自定義這些按鈕?與提醒應用程序的操作方式類似,您可以使用這兩個按鈕代替關閉選項自定義交互式通知按鈕

enter image description here

而這就是我得到:

enter image description here

可有人請澄清這是怎麼回事?

回答

0

你可以通過改變它們的值自定義按鈕標題,這裏有一個例子:

UIAlertView* alert; alert = [[UIAlertView alloc] initWithTitle:@"Reminder" message:@"Reminder" delegate:nil cancelButtonTitle:@"Mark as Completed" otherButtonTitles: @'Later']; [alert show]; [alert release];

這裏是推送通知的例子:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler 
{ 
if (application.applicationState == UIApplicationStateActive) { 
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Reminder" message:userInfo[@"Reminder"][@"alert"] delegate:nil cancelButtonTitle:@"Mark as Completed" otherButtonTitles:@"Later"]; 
[alertView show]; 
} 
else if (application.applicationState == UIApplicationStateBackground || application.applicationState == UIApplicationStateInactive) { 
} 
} 
+0

謝謝,但這是一個警報視圖,而不是通知 –

+0

這實際上是你要求的:D。 – AESTHETICS

+0

不,我說通知是作爲警報視圖呈現的?也就是說,不是鎖定屏幕或橫幅 –

0

沒有,有沒有辦法改變這一點,它將只是關閉和選擇。

提醒應用程序有不同的情況,它只有iOS版本。所以它基本上是這樣編碼的。

但是在應用程序開發中,我們可以改變它。

+0

如果幫助,您可以接受答案。 – Hasya