0
我是UILocalNotification概念的新手。在按鈕頂部顯示UIlocalNotification徽章號
我有一個提醒按鈕,通過點擊它IAM調用UILocalNotification代碼......
-(void)LocalNotificationMethod{
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
// Get the current date
NSDate *pickerDate = self.selectedDate;
NSLog(@" self.selectedDate %@", self.selectedDate);
// Break the date up into components
NSDateComponents *dateComponents = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit)
fromDate:pickerDate];
NSDateComponents *timeComponents = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit)
fromDate:pickerDate];
// Set up the fire time
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setDay:[dateComponents day]];
[dateComps setMonth:[dateComponents month]];
[dateComps setYear:[dateComponents year]];
[dateComps setHour:[timeComponents hour]];
// Notification will fire in one minute
[dateComps setMinute:[timeComponents minute]];
[dateComps setSecond:[timeComponents second]];
NSDate *itemDate = [calendar dateFromComponents:dateComps];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = itemDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif.alertBody = [_titleTextFieldObj text];
// Set the action button
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
localNotif.userInfo = infoDict;
NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
//UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row];
NSLog(@"notif %@",notificationArray);
//[cell.textLabel setText:notif.alertBody];
//[cell.detailTextLabel setText:[notif.fireDate description]];
//NSDate *datee=notif.fireDate;
//NSLog(@"notify date is %@",datee);
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
IAM獲得alert.But我想顯示在提醒按鈕的通知徽章。 如果我有兩個通知,那麼我想要得到按鈕中的2badge數字。 沒有在應用程序圖標... 誰能幫助我......
採取與圓潤風格的小圖像,並把它放在按鈕的右上角,並採取對ImageView的標籤和更新您的應用程序添加
Custom badge
是拉布勒文本作爲你的徽章數量,在徽章計數爲0時隱藏標籤和圖像查看。 – Max 2014-11-06 04:50:31