我的Xcode项目最近使用故事板进入一个非常奇怪的状态:Xcode不断构建整个项目,特别是每个按键后的故事板.我发现没有理由在我的项目中将所有有趣的文件(故事板和项目)区分为Xcode中的设置(也许我只是找不到它).不用说这个"功能"使我的项目工作几乎不可能因为当我键入新代码时,CPU一直在占用重建故事板.有谁见过这个?
我已经解决了将XML RSA私钥转换为PEM文件的问题,但是我遇到另一个问题,即在导入P12私钥时我得到空数据.以下是我的步骤:
将PEM文件转换为P12文件
openssl> pkcs12 -export -in rsa.pem -inkey rsa.pem -out rsa.p12 -nocerts
Run Code Online (Sandbox Code Playgroud)将P12文件读入iOS项目
NSString *path = [[NSBundle bundleForClass:[self class]]
pathForResource:@"MyPrivateKey" ofType:@"p12"];
NSData *p12data = [NSData dataWithContentsOfFile:path];
if (![self getPrivateKeyRef])
RSAPrivateKey = getPrivateKeywithRawKey(p12data);
Run Code Online (Sandbox Code Playgroud)导入P12私钥
SecKeyRef getPrivateKeywithRawKey(NSData *pfxkeydata)
{
NSMutableDictionary * options = [[[NSMutableDictionary alloc] init] autorelease];
// Set the public key query dictionary
//change to your .pfx password here
[options setObject:@"MyPassword" forKey:(id)kSecImportExportPassphrase];
CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL);
OSStatus securityError = SecPKCS12Import((CFDataRef) pfxkeydata,
(CFDictionaryRef)options, &items);
CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, …Run Code Online (Sandbox Code Playgroud)如何使用生成内联输出的主体创建汇合宏?以下宏:
## @noparams
<font color="red">$body</font>
Run Code Online (Sandbox Code Playgroud)
适用于本文
Before macro [macro starts here]macro body[macro ends here] after macro.
Run Code Online (Sandbox Code Playgroud)
将创建此HTML代码:
<p>Before macro </p>
<font color="red">macro body</font>
<p>after macro.</p>
Run Code Online (Sandbox Code Playgroud)
如何删除<p></p>标签?
我想继承一个具有工厂方法的框架类.如何使工厂方法返回我继承的类类型的对象?我发现这篇有用的文章描述了类似的情况,但在他们的情况下你可以控制超类.我怎么能写一个子类,UIImage它imageNamed:会返回我的子类类型的对象?
我已经用自制软件在 mac 上安装了 python。一些工具(例如 pipenv)有一些麻烦,因为它们尝试写入/lib/python3.7/site-packages/,在 mac 下是不允许的。经过一番调查,我发现他们启动了一个新的python解释器,其中发现sys.executable与自制软件安装的python路径实际上不一致。
$ which python
/usr/local/bin/python
$ python -c "import sys; print(sys.executable)"
/usr/local/opt/python/bin/python3.7
Run Code Online (Sandbox Code Playgroud)
我希望这些路径指向同一个二进制文件,为什么不是这样?我怎样才能控制sys.executable?
我需要打开一个CFStream套接字连接到具有不受信任的CA根的服务器.我有服务器的证书,我可以从中创建一个SecCertificateRef结构.问题是如何设置流的属性.
我想我应该将kCFStreamPropertySSLSettings属性设置为CFDictionary依次包含kCFStreamSSLCertificates密钥.根据文档,这个键应该包含一个"SecCertificateRefs的CFArray,除了数组中的第一个元素,它是一个SecIdentityRef".现在我可以创建SecCertificateRef我将随应用程序一起提供的服务器证书,但是如何获得SecIdentityRef?我想它应该是客户端身份,但我现在绝对不想要客户端身份验证.而且我找不到如何仅使用服务器证书来提供CFStream的方法.
注意,我不想将不受信任的证书添加到钥匙串,也不要在设置中禁用kCFStreamSSLValidatesCertificateChain.我需要接受服务器身份验证,只要它基于我自己从磁盘加载的服务器证书数据,并且只在此CFStream上.
我试图编写一个应用程序,可以打开NSDocument子类中的任何文件夹,但无法找出正确的Info.plist设置.重要的是我的应用程序不应该使用捆绑包,也不应该使用具有特定文件扩展名的文件夹,只能打开任何文件夹.
我尝试了什么:
如何在打开的文件对话框中打开任何文件夹?
我最近注意到以下表达式在我的编译器(Clang)中编译:
float a;
if (0.0 < a < 1.0) { ... }
Run Code Online (Sandbox Code Playgroud)
这是否符合我的期望?我希望它的评估与这种情况相同:
if (0.0 < a && a < 1.0) { ... }
Run Code Online (Sandbox Code Playgroud)
如果是这样,那么何时以及与其他编译器一起编写这种简短形式的条件?
我想在我的iOS应用程序中创建一个类似橡胶的按钮:当用户点击按钮时,它会缩小其框架,当用户释放水龙头时,它会增长,展开一点然后再转回原来的大小弹跳效果就像是用橡胶制成的.我在其他一些应用程序中看到了这种按钮,我很确定他们使用iOS 7 UIKit动态来实现这种效果.我检查了UIKit动力学的不同行为,但它们似乎都没有用,因为它们都没有改变框架的大小.我想知道是否有任何关于如何实现此行为的提示?
我在OpenCV网站上关注iOS视频处理教程,并设法在设备上编译和安装它.但是当我点击"开始"按钮时,没有任何可见的事情发生.显然我的- (void)processImage:(Mat&)image回调从未被调用过.你能给我一些提示可能是什么问题吗?
我查了一些东西:
actionStart 被调用,两个日志行都打印为YESself分配给该对象时有效self.videoCamera.delegateimageView 在屏幕上有效且可见videoCamera在start调用其方法时初始化我使用iPhone 3GS进行测试.
这是我的ViewController.h的完整源代码:
#import <UIKit/UIKit.h>
#import <opencv2/highgui/cap_ios.h>
@interface ViewController : UIViewController <CvVideoCameraDelegate>
{
IBOutlet UIImageView* imageView;
IBOutlet UIButton* button;
CvVideoCamera* videoCamera;
}
- (IBAction)actionStart:(id)sender;
@property (nonatomic, strong) CvVideoCamera* videoCamera;
@end
Run Code Online (Sandbox Code Playgroud)
和ViewController.mm:
@implementation ViewController
@synthesize videoCamera;
- (void)viewDidLoad
{
[super viewDidLoad];
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
self.videoCamera.delegate = self;
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.videoCamera.defaultFPS = 30; …Run Code Online (Sandbox Code Playgroud) 我写了一些代码来将imageview旋转90度然后翻转它.然而翻转似乎切断了一半的图像.为什么会这样?
UIImageView *tempView = [[UIImageView alloc] initWithFrame:button.frame];
tempView.image = [UIImage imageNamed:@"propertyCard.png"];
//tempView.backgroundColor = [UIColor redColor];
tempView.opaque = YES;
[self.view addSubview:tempView];
[UIView animateWithDuration: 1
delay: 0
options: UIViewAnimationOptionBeginFromCurrentState
animations:^{
// rotate
tempView.layer.transform = CATransform3DMakeRotation(M_PI /2, 0., 0, 1);
}
completion:^(BOOL finished) {
[self showPropertyViews];
[UIView animateWithDuration: 1
delay: 0
options: UIViewAnimationOptionBeginFromCurrentState
animations:^{
// flip
tempView.layer.transform = CATransform3DMakeRotation(M_PI, 1.0,1.0,0.0);
}
completion:^(BOOL finished) {
[UIView animateWithDuration: 1
delay: 0
options: UIViewAnimationOptionBeginFromCurrentState
animations:^{
tempView.frame = CGRectMake(propertyView.frame.origin.y + 12, propertyView.frame.origin.x +12, propertyView.frame.size.height-20, propertyView.frame.size.width-20);
tempView.center = …Run Code Online (Sandbox Code Playgroud) ios ×6
iphone ×6
objective-c ×3
xcode ×2
build ×1
c ×1
cocoa ×1
confluence ×1
expression ×1
file-type ×1
homebrew ×1
if-statement ×1
inheritance ×1
macos ×1
macros ×1
nsdocument ×1
oop ×1
opencv ×1
openssl ×1
pipenv ×1
pkcs#12 ×1
python ×1
rsa ×1
security ×1
ssl ×1
storyboard ×1
sys ×1
transitions ×1