我对如何以及何时使用感到困惑beginBackgroundTaskWithExpirationHandler.
Apple在他们的示例中显示在applicationDidEnterBackground委托中使用它,以便有更多时间来完成一些重要任务,通常是网络事务.
在查看我的应用程序时,似乎我的大多数网络内容都很重要,当一个人启动时,如果用户按下主页按钮,我想完成它.
因此,beginBackgroundTaskWithExpirationHandler为了安全起见,包装每个网络事务(并且我不是在谈论下载大量数据,大多数是短xml)是接受/良好做法 吗?
network-programming objective-c multitasking ios background-thread
iOS-app最小化时如何从相机拍照?
(即applicationDidEnterBackground:/ 之后applicationWillResignActive:)
AppDelegate.m: (感谢你链接)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//To make the code block asynchronous
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//### background task starts
NSLog(@"Running in the background\n");
while(TRUE)
{
printf("Called"); //////Work fine
[self.window.rootViewController captureNow]; /////Capture picture!
[NSThread sleepForTimeInterval: 10.0]; //wait for 10 sec
}
});
return YES;
}
Run Code Online (Sandbox Code Playgroud)
OurViewController.m: (感谢你链接)
-(IBAction)captureNow {
AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in _stillImageOutput.connections)
{
for (AVCaptureInputPort *port in [connection inputPorts])
{
if ([[port …Run Code Online (Sandbox Code Playgroud) 是否可以Home Screen从我的应用程序内部以编程方式截取屏幕截图?

谢谢!
我想知道如果在iOS7中,使用新的API,它最终可以在后台响应通知,在我的情况下,我有以下观察者:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(storeChanged:)
name:EKEventStoreChangedNotification
object:eventStore];
Run Code Online (Sandbox Code Playgroud)
我完全收到通知但我需要运行应用程序以便调用选择器.我已经浏览了回复,他们说这是不可能的,但不确定他们是否具体指的是iOS7.
有什么想法吗?
谢谢!
ios ×4
objective-c ×3
cocoa-touch ×2
avfoundation ×1
eventkit ×1
ios7 ×1
multitasking ×1
screenshot ×1