我真正要问的是这个;如果存在无法编译到统一构建中的依赖项,有没有办法仍然从统一内部调用它们并简单地使用从网站加载到浏览器中的脚本并与它们通信?
相关文档没有深入解决这个问题:https : //docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
我正在为统一应用程序创建一个网站包装器。体验按钮位于网站内,因为按钮影响网站的其余部分,而不仅仅是统一应用程序。
然而,当在统一游戏中加载某些内容时,应用程序需要能够影响网站。有没有办法以创造性的方式将数据传回网站?目前,我将网站的所有 javascript 代码都包含在统一编译中,并且出现以下错误:
gameInstance = UnityLoader.instantiate("gameContainer", "/Build/DomumProto16_Web.json", {
onProgress: UnityProgress
});
Run Code Online (Sandbox Code Playgroud)
从网站向游戏发送数据:
gameInstance.SendMessage('Manager','Filter', JSON.stringify(filterActive));
Run Code Online (Sandbox Code Playgroud)
需要从统一游戏中调用这个函数。但是,ajax.ajax_url 未定义,因为它在后端使用 wp_localize_script() 进行了本地化。
function showStudentWork(studentIndex){
//make sure to remove all the
var x = document.getElementById("studentWork");
var studentID = studentWork[studentIndex];
console.log(studentID);
$.ajax({
url: ajax.ajax_url,
type: "POST",
data: {
action: 'getStudentPost',
currentStudent: studentID
},
success: function (data) {
x.innerHTML = "";
x.innerHTML = data;
x.style.display = "grid";
},
error: function (error) {
console.log(`Error ${error}`);
}
});
return false;
}
Run Code Online (Sandbox Code Playgroud)
我真正要问的是这个;如果存在无法编译到统一构建中的依赖项,有没有办法仍然从统一内部调用它们并简单地使用从网站加载到浏览器中的脚本并与它们通信?
我的网址是:
http://www.mapquestapi.com/geocoding/v1/batch?key=dNBvDLtTx85L3akdg8vBoHQXrWpDJSEI&location=HEBRON,KY,US&location=CINCINNATI,KY,US&location=CINCINNATI,KY,US&location=BEDFORD PARK,IL,US&location=BEDFORD PARK,IL,US&location=HODGKINS,IL,US&location=HODGKINS,IL,US&location=HODGKINS,IL,US&location=BALDWIN PARK,CA,US&location=BALDWIN PARK,CA,US&location=BALDWIN PARK,CA,US&location=,,US
Run Code Online (Sandbox Code Playgroud)
很长,但是应该符合https://www.mapquestapi.com/geocoding/
当我运行以下php代码时,谜团就揭开了帷幕:
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, $urlForGeocode);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
$return = curl_exec ($ch);
curl_close ($ch);
echo( $return);
$output = shell_exec('curl ' . $urlForGeocode);
echo( $output);
Run Code Online (Sandbox Code Playgroud)
该变量$urlEncode保存上面url的值。第一个输出是:
<html><body><b>Http/1.1 Bad Request</b></body> </html>
Run Code Online (Sandbox Code Playgroud)
第二个请求的输出是:
{
"info": {
"statuscode": 400,
"copyright": {
"text": "\u00A9 2016 MapQuest, Inc.",
"imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
"imageAltText": "\u00A9 2016 MapQuest, Inc."
},
"messages": ["no 'json' parameter found"]
},
"options": { …Run Code Online (Sandbox Code Playgroud) 由于自 iOS7 以来的广泛更新,我想问这个问题,因为我对自动布局和新堆栈视图的经验有限,我想知道在 Objective-C 中实现以下内容的最佳设计实践是什么(还不是 swift ):
在我看来,有一个容器滚动视图,带有一个子容器 UIView。在这个 UIView 中,有许多元素。其中一个元素是一堆 UIViews,它们的数量偶尔会有所不同。
此元素后跟地图和其他视图。
问题
我正在使用一个名为objective zip的库来提取文件.
相关代码:
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:requestFinishedPresentationPath mode:ZipFileModeUnzip];
NSArray *infos= [unzipFile listFileInZipInfos];
for (FileInZipInfo *info in infos) {
NSLog(@"- %@ %@ %d (%d)", info.name, info.date, info.size, info.level);
[unzipFile locateFileInZip:info.name];
// Expand the file in memory
ZipReadStream *read= [unzipFile readCurrentFileInZip];
NSMutableData *data = [[NSMutableData alloc] initWithLength:256];
int bytesRead = [read readDataWithBuffer:data];
[data writeToFile:[documentsDir stringByAppendingPathComponent:info.name] atomically:NO];
NSLog([documentsDir stringByAppendingPathComponent:info.name]);
[read finishedReading];
}
[unzipFile close];
Run Code Online (Sandbox Code Playgroud)
第一个nslog输出以下内容:
- _some-path_/modules/reference-popup/ref-popup.js 2012-08-21 08:49:36 +0000 109 …Run Code Online (Sandbox Code Playgroud) 我需要将视图控制器推送到另一个视图控制器.
menuVC -> VC1 ->VC2
Run Code Online (Sandbox Code Playgroud)
从menuVC到VC1不需要动画,但是从VC1到VC2以及从VC2到VC1需要翻转动画.
但是,从VC2转到menuVC时,不需要动画.
我使用以下代码:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
FlashCardVC *flashCardVC = [[FlashCardVC alloc] init];
[self.navigationController pushViewController:flashCardVC animated:NO];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
当我尝试执行上述操作时,屏幕完全空白.
怎么了?
有没有办法在NSDictionary中获取完全随机的密钥?
NSString *key = [enumeratorForKeysInDictionary nextObject];
Run Code Online (Sandbox Code Playgroud)
我有这个代码以非随机方式迭代字典.
我应该将所有密钥添加到NSSet然后从那里随机拉出来吗?
有没有更有效的方法来做到这一点?
我有一个问题:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {}
Run Code Online (Sandbox Code Playgroud)
只能通过相机调用,而不是在我尝试浏览用户的照片时选择图像.
这是我的UIImagePicker委托的初始化代码:
-(void)viewDidLoad{
[self initImagePicker];
}
-(void)initImagePicker{
DLog(@"");
self.imagePickerController.delegate = self;
}
- (void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType
{
self.imagePickerController.sourceType = sourceType;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
// user wants to use the camera interface
//
self.imagePickerController.showsCameraControls = NO;
if ([[self.imagePickerController.cameraOverlayView subviews] count] == 0)
{
// setup our custom overlay view for the camera
//
// ensure that our custom view's frame fits within the parent frame
CGRect overlayViewFrame = self.imagePickerController.cameraOverlayView.frame;
CGRect newFrame = CGRectMake(0.0,CGRectGetHeight(overlayViewFrame)-15.0,CGRectGetWidth(overlayViewFrame),15.0);
self.view.frame …Run Code Online (Sandbox Code Playgroud) 这个问题已被要求在堆栈溢出时死亡,我已经看到过多的答案,但不知怎的,我仍然遇到麻烦.
无论如何,我在我的视图中分配了一个NSTimer,所以加载:
NSTimer *oneSecondTicker = [[NSTimer alloc] init];
oneSecondTicker = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateLabelsWithOneSecondTicker) userInfo:nil repeats:YES];
self.dateForTimeLabel = [NSDate date];
Run Code Online (Sandbox Code Playgroud)
选择器的方法是:
-(void) updateLabelsWithOneSecondTicker {
if(self.dateForTimeLabel != nil)
{
self.lblTime.text = [NSString stringWithFormat:@"%f", fabs([self.dateForTimeLabel timeIntervalSinceNow])];
}
}
Run Code Online (Sandbox Code Playgroud)
这种方法基本上每秒更新一个标签,给我一个定时器/秒表的东西.
我还有一个开始/暂停按钮,当按下暂停时会执行以下操作:
[oneSecondTicker invalidate];
oneSecondTicker = nil;
Run Code Online (Sandbox Code Playgroud)
如果按下按钮再次启动,方法是:
NSTimer *oneSecondTicker = [[NSTimer alloc] init];
oneSecondTicker = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateLabelsWithOneSecondTicker) userInfo:nil repeats:YES];
self.dateForTimeLabel = [NSDate date];
Run Code Online (Sandbox Code Playgroud)
我没有调用保留到计时器,它没有属性,也没有合成.然而,它在界面中声明.
为了解决这个问题,按下每个暂停/开始按钮会发生什么,定时器不会失效,时间标签会更快更快地更新,这让我相信多个定时器由于某种原因而存在.(显然,在这些方法中还没有找到真正计时器的功能,这只是让我的NSTimer工作的一个测试).
怎么会这样?
我希望实现类似于圆形html表单的效果,其透明背景类似于下面的图像(不是鼠标悬停文本,只是背景中的矩形,并且具有不透明度).
我不知道怎么做这个,我玩弄了,CGRect但我甚至无法让它们上来.我正在使用基于标签导航的iPad模板.
你能指点一些可以让我入手的资源CGRect吗?

ios ×7
objective-c ×4
iphone ×3
c# ×1
cgrect ×1
curl ×1
insets ×1
ipad ×1
javascript ×1
mapquest ×1
nsdictionary ×1
nsset ×1
nstimer ×1
php ×1
uiscrollview ×1
uistackview ×1
uitableview ×1
uiview ×1
wordpress ×1
zip ×1