1

iPhoneの「ことわざ」アプリにローカル通知を使用しています。毎日(午前11時53分)、アプリからのことわざをユーザーに通知する必要があります。ここで私の問題は、userinfoプロパティを使用するための適切な参照を取得できないことです。これを別の方法でやろうとしました.アプリが通知を受け取るたびにインクリメントされる整数変数を使用しましたが、それもうまく機能していません.ローカル通知は毎日同じことわざを示しています..これを解決するのを手伝ってください..これは私のコードです.....

- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar] ;

NSDateComponents *componentsForReferenceDate =

[calendar components:(NSDayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit )        fromDate:[NSDate date]];

[componentsForReferenceDate setDay:11] ;
[componentsForReferenceDate setMonth:6] ;
[componentsForReferenceDate setYear:2013] ;

NSDate *referenceDate = [calendar dateFromComponents:componentsForReferenceDate] ;

// set components for time 7:00 a.m.

NSDateComponents *componentsForFireDate =

[calendar components:(NSYearCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit|   NSSecondCalendarUnit ) fromDate: referenceDate];

[componentsForFireDate setHour:11] ;
[componentsForFireDate setMinute:53] ;
[componentsForFireDate setSecond:0] ;

NSDate *fireDateOfNotification = [calendar dateFromComponents: componentsForFireDate];

// Create the notification

UILocalNotification *notification = [[UILocalNotification alloc]  init] ;
DataHandler *obj=[[DataHandler alloc] init];

notification.fireDate =  [NSDate dateWithTimeIntervalSinceNow:1];//fireDateOfNotification    ;
notification.timeZone = [NSTimeZone localTimeZone] ;
notification.alertBody = [obj.proverb objectAtIndex:sectionindex];//[objz[NSString   stringWithFormat: @"അകലത്തെ ബന്ധുവിനേക്കാൾ അരികത്തെ ശത്രു നല്ലത് ."] ;
notification.alertAction = @"go back";
notification.userInfo= [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Some information"] forKey:@"information"];
notification.repeatInterval= NSDayCalendarUnit ;
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:notification] ;


}

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
DataHandler *obj=[[DataHandler alloc] init];
static int i=0;
NSLog(@"hai");
UILabel *label=[UILabel alloc];
UILabel *label1=[UILabel alloc];


label.text=[obj.explanation objectAtIndex:i];
label1.text=[obj.proverb objectAtIndex:i];
UIAlertView *message = [[UIAlertView alloc] initWithTitle:label1.text
                                                  message:label.text
                                                 delegate:nil
                                        cancelButtonTitle:@"OK"
                                        otherButtonTitles:nil];
[message show];
i++;
sectionindex++;

}

4

2 に答える 2

2

アクションボタン(hasAction = NO)のみカスタマイズできます。表示されたテキストでは何もできません。テキストの長さがそれ以上の場合、テキストの一部のみが表示されます。

テキストの部分だけで十分だと思いますAs happy as a clam at high water," is a very common.....。ユーザーが全文を表示したい場合は、ユーザーがアプリを開いてそこに表示できるようにします

于 2013-06-07T04:05:23.200 に答える