我正在为iOS制作多人游戏,我在Apple开发者中心阅读了这个材料,特别是这个.这是我的自定义配对代码,非常简单:
- (void)findProgrammaticMatch {
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 2;
request.defaultNumberOfPlayers = 2;
request.playersToInvite = nil;
request.playerAttributes = 0;
request.playerGroup = 0;
UILabel *loading = (UILabel *)[aiw viewWithTag:792];
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
if (error){
//error handling
[loaderLayer stopAnimating];
UIButton *cancelButton = (UIButton *)[loaderLayer viewWithTag:442];
[cancelButton setTitle:@"Go Back" forState:UIControlStateNormal];
loading.text = @"Cannot find any players. Please try again later.";
} else if (match != nil) {
//save match
self.match …Run Code Online (Sandbox Code Playgroud) 我有一个带有QR码扫描仪的应用程序可以正常工作,但在iOS 8上,对相机的默认访问是"拒绝".因此,我必须进入设置并手动授予应用程序访问权限以使用相机.如何提示"你想让这个应用程序访问使用相机"这样的提示吗?
以下是我的代码检查相机权限的示例,然后在用户未提供权限时请求权限.但是,提供权限的链接永远不会显示,最终只显示UIAlertView.我测试时状态确实是DENIED,所以有没有理由不要求权限?谢谢!
我也有#import AVFoundation/AVFoundation.h,所以这不是问题.
-(void) checkCameraAuthorization {
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(status == AVAuthorizationStatusAuthorized) { // authorized
NSLog(@"camera authorized");
}
else if(status == AVAuthorizationStatusDenied){ // denied
if ([AVCaptureDevice respondsToSelector:@selector(requestAccessForMediaType: completionHandler:)]) {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
// Will get here on both iOS 7 & 8 even though camera permissions weren't required
// until iOS 8. So for iOS 7 permission will always be granted.
NSLog(@"DENIED");
if (granted) {
// Permission has been granted. Use dispatch_async for any …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个UniMRCP插件.从文档中不清楚如何使用插件处理来自客户端的多个同时请求.以下哪个选项是这样的?
根据上面的答案,实现插件的最佳策略是什么.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
ChildViewController *childviewcontroller = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
[self addChildViewController:childviewcontroller];
[self.view addSubview:childviewcontroller.view];
[childviewcontroller willMoveToParentViewController:self];
UIView *cview = [[UIView alloc] init];
cview = childviewcontroller.view;
[self.view removeConstraints:self.view.constraints];
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(cview);
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|-[cview]-|"
options:0 metrics:nil
views:viewsDictionary]];
}
Run Code Online (Sandbox Code Playgroud)
我想在父视图上添加childviewcontroller视图.添加后我设置了约束,但它对我不起作用.
我也收到这样的警告
2013-07-25 10:47:30.564 neenah[1105:c07] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try …Run Code Online (Sandbox Code Playgroud) Hi I have a project in node.js and I want to set the HttpOnly flag: true for header response.
I have written the following code in app.js but it make no effect in response header .
app.use(session({
secret: "notagoodsecretnoreallydontusethisone",
resave: false,
saveUninitialized: true,
cookie: {httpOnly: true, secure: true}
}));
Run Code Online (Sandbox Code Playgroud)
因此,对于设置任何建议的HttpOnly标志中express.js深受欢迎。
这是我遇到的问题.
首先,我正在开展几个不同的项目.我有两个不同的github帐户,在设置其中一个并成功推送回购后,我需要提交/推送其他回购到第二个帐户,这让我遇到了确切的问题.
如何使用https方式而不是ssh在这两个帐户之间切换?
PS:我在Mac上.
我试图改变git config全局/本地用户名和电子邮件,但它没有成功.我一直得到同样的错误:
"remote:对用户拒绝命名/ repo.git的权限.致命:无法访问'repos地址':请求的URL返回错误:403".
所以这是一个奇怪的问题.我有一个响应touchesMoved:&的UIImageView touchesBegan:,它完美地运行.我遇到的主要问题是如果你把手指放在说image1然后然后用手指按住图像1你会用另一根手指按下image2.
反过来,这将再次触发image1.不希望这种情况发生.我希望能够在同时推动两个图像时使用Multi Touch,而不是一遍又一遍地触发它们.必须有一些东西我必须添加,以阻止这种情况发生.
码:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches];
for (UITouch *touch in allTouches)
{
CGPoint location = [touch locationInView:touch.view];
if(CGRectContainsPoint(image1.frame, location) && lastButton != image1) {
//Play Sound
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound1"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
, &soundID);
AudioServicesPlaySystemSound (soundID);
//
lastButton = image1;
}
if(CGRectContainsPoint(image2.frame, location) && lastButton != image2) {
//Play Sound
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound2"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
, &soundID); …Run Code Online (Sandbox Code Playgroud) 我有一个UISplitViewController嵌入在UINavigationController中,带有UINavigationItem按钮,可以纵向切换主视图的显示.我想在纵向首次加载纵向时显示详细视图上方的主视图.
我发现的任何类似的例子都显示了纵向分割屏幕的主视图和细节视图,但是当UISplitViewController首次加载时,我需要将详细视图全屏显示为包含详细视图的主视图(就像主视图一样)已被从左侧滑出).有谁知道这是怎么做到的吗?
我使用Sprite Kit开发了一个iOS应用程序.任何使用Sprite Kit开发iOS游戏的人都知道底部的标签带有调试信息.我试图删除底角的调试信息,它给出了节点数和fps数.(例如1节点60.0 fps)
我-(id)initWithSize:(CGSize)size在我的.m文件中的方法中尝试了以下代码,但它似乎没有做任何事情.这是删除调试标签的正确代码还是有更好的方法来删除标签?
SKView *spriteView = (SKView *) self.view;
spriteView.showsNodeCount = NO;
spriteView.showsFPS = NO;
Run Code Online (Sandbox Code Playgroud) 我正在使用iOS 9新的Contact框架,我无法弄清楚如何从CNContact上的phoneNumbers键获取数字.
做CNContact的NSLog我得到这个输出:
<CNContact: 0x14f57e680: identifier=1B39B156-A151-4905-9624-
DB117ACFBADC, givenName=John, familyName=Doe,
organizationName=CompanyName, phoneNumbers=(
"<CNLabeledValue: 0x154297a40: identifier=3FEB6B0C-7179-4163-93E6-63C156C2F02B,
label=_$!<Mobile>!$_, value=<CNPhoneNumber: 0x155400e00: countryCode=us,
digits=1234567890>>"
), emailAddresses=(
), postalAddresses=(
)>
Run Code Online (Sandbox Code Playgroud)
我可以像这样获取givenName和familyName的键:
CNContact *contact;
[contact valueForKey:@"givenName"]
[contact valueForKey:@"familyName"]
Run Code Online (Sandbox Code Playgroud)
如何获取phoneNumbers键下的数字值?
ios ×6
objective-c ×6
iphone ×2
autolayout ×1
avfoundation ×1
camera ×1
cncontact ×1
cocoa-touch ×1
express ×1
gamekit ×1
git ×1
github ×1
ios7 ×1
ios8 ×1
javascript ×1
node.js ×1
nsautolayout ×1
sprite-kit ×1
unimrcp ×1
xcode ×1