我想制作一个后台服务,如果用户打开应用程序并在每分钟后关闭一个操作视图将显示该视图将播放视频,该视频也来自服务器端。如果可能的话?
答案 0 :(得分:0)
您可以在3天内完成此操作
创建一个NSTimer对象作为实例变量,以及一个计数计数器的整数。
@implementation myClass {
NSTimer *myTimer, int counter;
}
-viewDidLoad{
counter = 61;
myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkTimer) userInfo:nil repeats:YES];
}
-(void)checkTimer{
if(counter <=1){
counter = 61;
}
else {
counter --;
//do your video playing work here
}
}
答案 1 :(得分:0)
[[UIApplication sharedApplication] cancelAllLocalNotifications];
NSCalendar *gregCalendar12 = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *dateComponent12 = [gregCalendar12 components:NSCalendarUnitWeekday | NSCalendarUnitHour | NSCalendarUnitMinute fromDate:[NSDate date]];
[dateComponent12 setWeekday:7];
[dateComponent12 setHour:14];
[dateComponent12 setMinute:46];
UILocalNotification *notification12 = [[UILocalNotification alloc]init];
[notification12 setAlertBody:@"u got message!"];
[notification12 setFireDate:[gregCalendar12 dateFromComponents:dateComponent12]];
notification12.repeatInterval = NSCalendarUnitMinute;
notification12.applicationIconBadgeNumber+=1;
[notification12 setTimeZone:[NSTimeZone defaultTimeZone]];
[[UIApplication sharedApplication] scheduleLocalNotification:notification12];