Tag: cocoa

在Objective-C / cocoa中创build文件夹/目录

我有这个代码在Objective-C / cocoa中创build一个文件夹/目录。 if(![fileManager fileExistsAtPath:directory isDirectory:&isDir]) if(![fileManager createDirectoryAtPath:directory attributes:nil]) NSLog(@"Error: Create folder failed %@", directory); 它工作正常,但我得到了creatDirectoryAtPath:attributes is deprecated警告消息。 在Cocoa / Objective-c中制作目录生成器的最新方法是什么? 解决了 BOOL isDir; NSFileManager *fileManager= [NSFileManager defaultManager]; if(![fileManager fileExistsAtPath:directory isDirectory:&isDir]) if(![fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:NULL]) NSLog(@"Error: Create folder failed %@", directory);

使用CALayer时无法编译代码

出于某种原因,当我尝试使用CALayer时,出现链接器错误: "_OBJC_CLASS_$_CALayer", referenced from: 我已经导入了以下标题: #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> 码: arrowImage = [[CALayer alloc] init];

显示UIAlertView时播放本地通知默认声音?

我正在写一个iPhone的提醒应用程序,显示使用本地通知提醒。 如果在应用程序运行时提醒消失,则不会显示本地通知。 相反,我的应用程序委托中调用了didReceiveLocalNotification方法,并通过显示带有提醒文本的UIAlertView模拟本地通知对话框。 当本地通知显示在应用程序外部时,设备会振动并播放由UILocalNotificationDefaultSoundName指定的声音。 同样,我想在显示UIAlertView时在应用程序中模仿这个。 我可以通过调用AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)振动设备,但我不知道如何播放本地通知默认声音。 没有等效的SystemSoundID常量,我不确定path是什么。 tl; dr在显示UIAlertView时,我想播放本地通知的默认声音。 有任何想法吗?

NSUserNotification不显示操作button

我正在使用这个代码: – (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application NSUserNotification *notification = [[NSUserNotification alloc] init]; [notification setTitle: @"Title"]; [notification setSubtitle: @"Subtitle"]; [notification setInformativeText: @"Informative Text"]; [notification setHasActionButton: YES]; [notification setActionButtonTitle: @"Action Button"]; [notification setOtherButtonTitle: @"Other Button"]; [notification setSoundName: NSUserNotificationDefaultSoundName]; [notification setDeliveryDate: [NSDate dateWithTimeIntervalSinceNow: 10]]; [[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification: notification]; } 而且我越来越多, 没有操作button或其他button。

IOS的最佳射频button实现

我想问一下在iPhone应用上如何实现radio-button选项。 我发现Picker View对于一个简单的selectfunction来说相当大。 我不确定苹果是否故意排除单选button,以及从可用性/用户体验angular度来看是否更好地使用选取器视图。

UITableViewController上边距

我有一个TabBarController,其中的一个选项卡包含一个导航控制器的子视图。 我然后加载到导航控制器的视图inheritanceformsUITableViewController。 我的问题是由于某种原因,表视图开始冲击导航控制器,而不是屏幕的顶部,但大约在导航栏的一半处,因此表格视图中第一个单元格的顶部被截断。 任何人都可以build议如何移动UITableViewController?

从UIImageView中删除图像

我用一个图像加载一个UIImageView取决于用户的交互。 当初始显示父视图时,没有select图像并且图像视图是黑色的。 如果用户离开视图并返回,图像仍然存在。 我试过了 myImageView.image = nil; 在离开视图后,但图像依然存在。 如何删除图像,使UIImageView再次显示黑色? 该 的UIImageView 通过IB连接。

如何把NSWindow带到前面和现在的空间?

我正在使用这个代码来调出我的窗口: [self.window makeKeyAndOrderFront:self]; [self.window setOrderedIndex:0]; 但是经常会在其他窗口下面显示,或者显示在我最后打开的其他空间桌面中。如何使它始终显示在用户的“前面”? 更新我从以前问的问题find答案; 使窗口显示在其他窗口的顶部:[NSApp activateIgnoringOtherApps:YES]; 但如何将应用程序移动到用户的当前空间?

如何在Cocoa中创build一个string的MD5散列?

我知道SHA-1是首选,但是这个项目需要我使用MD5。 #include <openssl/md5.h> – (NSString*) MD5Hasher: (NSString*) query { NSData* hashed = [query dataUsingEncoding:NSUTF8StringEncoding]; unsigned char *digest = MD5([hashed bytes], [hashed length], NULL); NSString *final = [NSString stringWithUTF8String: (char *)digest]; return final; } 我从StackOverflow上的另一个类似问题的答案中得到了这段代码,但是当程序在返回final时发生了下面的错误: (gdb) p digest $1 = (unsigned char *) 0xa06310e4 "\0206b\260/\336\316^\021\b\a/9\310\225\204" (gdb) po final Cannot access memory at address 0x0 (gdb) po […]

如何在iphone上完成透明的rect视图?

当运行耗时的操作时,许多应用程序popup一个透明的圆angular视图和一个activityIndi​​cator。 这个舍入是如何完成的,是否可以使用Interface Builder来完成(因为有很多地方我想使用类似的东西)? 或者,我应该使用一个圆形矩形或可伸缩图像的图像视图? 我需要自己画背景吗? 到目前为止,通过在界面生成器中设置alphaValue,我设法得到了一个具有相似透明度的基本视图,但是它没有圆angular,透明度似乎也适用于所有子视图(我不想要文本和活动指示符是透明的,但是即使我在IB中设置alphaValue它似乎被忽略)。