私はかなりユニティですが、私は研究の日後に解決できない問題に直面しています。作成したAppのカメラ権限がユーザーによって与えられていない場合、私のiPhone上で関数を実行したいだけです。私は以下のコードのようなアラートメッセージを表示したいと思います(これはalertView全体をif文の中に入れたときに動作します)。しかし、私はそこにこのIBActionを配置する方法を理解できません(ボタンも機能するように)。もしxCodeがintやbooleanのような変数をUnityに返すのであれば良いでしょうし、そこにいくつかの関数を実行してユーザにアドバイスを与えることができます。objc(Xcode)からUnityにboolを返すにはどうしたらいいですか?またはxCodeで関数を実行しますか?
ユーザーが
ユーザーが選ぶ "あなたがカメラ許可blablaを与える必要があり、" PIC
UIAlertがポップアップ表示にしたい「行く:
基本的流れは、次のことです設定を開き、設定を開きます。
ここで私がこれまで持っているコードです:
#include "PermissionCamPlugin.h"
#import "PermissionCamPlugin.h"
#import <Social/Social.h>
#import <Foundation/NSException.h>
#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>
@implementation alertViewController
-(IBAction)alertbutton
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"oops... "
message:@"If you want to enable the camera go to the settings."
delegate:self
cancelButtonTitle:@"close"
otherButtonTitles:@"go to settings", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 1)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
}
@end
BOOL CameraCheckDone = NO;
BOOL CamPermGiven = NO;
void sd_camera_permission()
{
if ([AVCaptureDevice respondsToSelector:@selector(requestAccessForMediaType:completionHandler:)]) {
// Completion handler will be dispatched on a separate thread
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if (YES == granted)
{
CamPermGiven = YES;
}
else
{
CamPermGiven = NO;
//HERE I WANT TO EXECUTE THE ALERT CALL AND ALSO EXECUTE THE BUTTON FUNCTION IF THE USER CHOOSES SO
}
// (no matter if the 'granted' is YES or NO)
CameraCheckDone = YES;
}];
}
else {
// iOS < 7 (camera access always OK)
CameraCheckDone = YES;
// Continue with app launch...
}
}
ありがとうございます!これは私の問題を解決しました。素敵な一日を。 –
私の喜び。名声 – uGk