我正在制作一个时钟应用程序,我想知道如何检查当前亮度级别设置为什么以及如何使用UISlider在xcode 4中调整应用程序的亮度,而不是告诉用户转到他们的iphone/ipad设置应用程序并调整亮度?我找不到任何代码/ api.
我在appstore中看过很多时钟应用程序,用户只需向上或向下移动手指即可调整显示屏的亮度.
有没有办法以编程方式更改WatchKit WKInterfaceButton标题的颜色?我知道我可以在故事板中更改它,但我需要在代码中更改它.
根据Apple文档,它没有说明是否允许此类操作.我确实尝试过查看WKInterfaceButton的所有可用方法,并且有一个用于setBackgroundColor但不用于标题颜色.我错过了什么?
这适用于 Windows 2012 服务器。我正在尝试终止在 cmd 窗口下运行的特定任务。
在这种特定情况下,我想杀死 SWIMAUX。我打开了一个命令提示符,每次使用 taskkill 命令时都会出现以下错误。我怎样才能杀死那个任务?
C:\Siemens\hot_cold_backups>taskkill /f /fi "imagename eq SWIMAUX"
INFO: No tasks running with the specified criteria.
C:\Siemens\hot_cold_backups>taskkill /f /fi "services eq SWIMAUX"
INFO: No tasks running with the specified criteria.
Run Code Online (Sandbox Code Playgroud) 我需要将Xcode 8.2更新为Xcode9。我将操作系统升级为macOs High Sierra 10.13。然后我去了Mac App Store并尝试下载它,并且更新按钮一直旋转到无限。我搜索了google和stackoverflow,显然这是一个已知的错误,可以追溯到很久以前。解决方案之一建议我删除Xcode应用程序,然后在App Store中再次尝试下载/更新按钮。
请参阅此处无法更新到Xcode 8.3
因此,如果我打算从计算机上完全删除Xcode应用程序,那么我想我应该清理我的组件并删除不需要的不必要的Xcode文件,它们将在新安装时重新创建。这些是巨大的文件夹,看起来与我的Xcode开发活动有关。我可以安全地删除它们吗?
我正在从google weather api读取XML文件并使用NSXMLParser解析它.有问题的城市是巴黎.这是我得到的简短的xml输出
<?xml version="1.0"?>
<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information>
<city data="Paris, Île-de-France"/>
<postal_code data="Paris"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
...
...
Run Code Online (Sandbox Code Playgroud)
现在我用来削减这个xml的代码是
NSString *address = @"http://www.google.com/ig/api?weather=Paris";
NSURL *URL = [NSURL URLWithString:address];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
[parser setDelegate:self];
[parser parse];
...
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
NSLog(@"XML Parser 1 ... elementName ... %@", elementName);
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的上述xml的输出
XML Parser 1 ... elementName ... xml_api_reply
XML Parser 1 ... …Run Code Online (Sandbox Code Playgroud) 我有一个NSdictonary对象具有以下键值
keys:1.infoKey,2.infoKey,3.infoKey,4.infoKey,5.infoKey,6.infoKey,7.infoKey,8.infoKey,9.infoKey,10.infoKey,11.infoKey
注意它们没有排序,可以是任何顺序,即3.infoKey,7.infoKey,2.infoKey等
我想要做的是排除键值,即1,2,3,4,5,6,7,8,9,10,11 ....这是我到目前为止使用的代码,但每次我做了一个排序,它按照我不想要的方式对其进行排序(见下文)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *stringsPlistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"talkBtns.plist"];
NSMutableDictionary *dictionary2 = [[NSMutableDictionary alloc] initWithContentsOfFile:stringsPlistPath];
NSArray *myKeys = [dictionary2 allKeys];
//This didn't give the right results
//sortedKeys = [myKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
//This didn't give the right results either
NSSortDescriptor* sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:nil ascending:YES selector:@selector(localizedCompare:)];
sortedKeys = [myKeys sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
// ***********
// GET KEY VALUES TO
// LOOP OVER
// ***********
/* */
for (int i = 0; i < [sortedKeys count]; …Run Code Online (Sandbox Code Playgroud) 我正在为iPad制作相机应用程序.我希望相机应用程序仅在纵向模式下工作.我不得不进行旋转观察,并强制设备使用纵向模式,如下所示:
Landscape中的UIImagePickerController
我认为这是私有API; 帖子上的一些用户建议它是.
如果是这样,我可以使用哪些其他工作来强制叠加层仅保持纵向模式?如果我不添加此代码,它将旋转为纵向和横向模式.
//Is this private?
@interface UIDevice ()
-(void)setOrientation:(UIDeviceOrientation)orientation;
@end
-(IBAction)InitiateCamera
{
overlayview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
...
...
//monitor device rotation
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
//launch camera
[self presentViewController:picpicker animated:YES completion:nil];
}
- (void) didRotate:(NSNotification *)notification
{
//IS THIS PRIVATE?
//Maintain the camera in portrait orientation
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud) 我正在制作一个视频应用程序,在其中使用AVAssetExportSession创建新视频。在创建视频时,我希望使用户能够取消视频创建。我遇到的问题是我不知道如何将取消请求发送到AVAssetExportSession,因为我假设它正在主线程上运行。一旦启动,我不知道如何发送停止请求?
我试过了但是没用
- (IBAction) startBtn
{
....
// Export
exportSession = [[AVAssetExportSession alloc] initWithAsset:[composition copy] presetName:AVAssetExportPresetHighestQuality];
[exportSession setOutputFileType:@"com.apple.quicktime-movie"];
exportSession.outputURL = outputMovieURL;
exportSession.videoComposition = mainComposition;
//NSLog(@"Went Here 7 ...");
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status])
{
case AVAssetExportSessionStatusCancelled:
NSLog(@"Canceled ...");
break;
case AVAssetExportSessionStatusCompleted:
{
NSLog(@"Complete ... %@",outputURL); // moview url
break;
}
case AVAssetExportSessionStatusFailed:
{
NSLog(@"Faild=%@ ...",exportSession.error);
break;
}
case AVAssetExportSessionStatusExporting:
NSLog(@"Exporting.....");
break;
}
}];
}
- (IBAction) cancelBtn
{
exportSession = nil;
}
Run Code Online (Sandbox Code Playgroud) 这应该是如此简单,但我正在努力解决它.我想要做的就是将NSURL文件从其位置复制到我的应用程序文档目录.我不想重命名该文件,并希望保持相同的名称.请注意,此文件来自电子邮件附件.
这是我到目前为止的代码
-(BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if (url != nil && [url isFileURL])
{
NSLog(@"url: %@ ...", url);
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask ,YES);
NSString* documentsPath = [paths objectAtIndex:0];
//Not sure what to do here. I could parse URL and get the last string out of it
// which is the file name but I am not sure that's easiest way to do things.
//[fileManager copyItemAtURL:url toURL:backupDir error:&error];
NSLog(@"Email …Run Code Online (Sandbox Code Playgroud) 我已经在我的应用程序中保存了一堆NSUserDefaults,现在我试图在Xcode 6中找到我的应用程序的plist文件.这是我的应用程序文档目录的路径.
/Users/xxx/Library/Developer/CoreSimulator/Devices/676A8C61-67E4-43E0-A051-DA8BD84A84F5/data/Containers/Data/Application/B2E3C89C-48B7-4429-BBE3-FB830CD040F2/Documents
Run Code Online (Sandbox Code Playgroud)
我已在文件夹中的所有位置搜索,但我找不到plist文件的位置?它位于其他地方吗?我需要在其中手动编辑NSUserDefaults.
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"firstTimeLaunch1257"];
[[NSUserDefaults standardUserDefaults] synchronize];
Run Code Online (Sandbox Code Playgroud)