我正在尝试$location.path从AngularJS指令中更新.它没有按照我的预期工作,即更新浏览器窗口中显示的URL并在我的页面上显示不同的内容.我的函数肯定会被调用正确的值,如控制台中所示.我认为$location.path可能会产生一些影响,因为当我点击链接时,会调用一些在新页面上调用的附加函数,只会显示新页面.当我$location.path在控制器中使用时,它按预期工作,但不在我的指令中.
这是我的指令的HTML:
<div detail-link="/comments?post={{post.postId}}" ng-click="clickDetailLink()"></div>
Run Code Online (Sandbox Code Playgroud)
这是指令的定义(在CoffeeScript中):
directives.directive 'detailLink', ['$location', ($location) ->
return (scope, element, attrs) ->
scope.clickDetailLink = ->
console.log "loading " + scope.detailLinkHref
$location.path scope.detailLinkHref
attrs.$observe 'detailLink', (value) ->
console.log "set detail link to " + value
scope.detailLinkHref = value
]
Run Code Online (Sandbox Code Playgroud)
我知道这里发生了什么......我$routeProvider已经设置好处理/comments但是在这里我试图将一个查询字符串附加到路由中.如果我使用常规<a href="#/comments?post={{post.postId}}">,这工作正常,但以某种方式设置相同的路线通过$location.path是行不通的.这与代码是否在控制器或指令中无关.
我从命令行构建一个全新的PhoneGap应用程序时遇到链接器错误.它创建了一堆文件,如果我打开.xcodeproj在Xcode中创建的文件,它就构建得很好.那我的命令行环境有什么问题?
$ phonegap create /tmp/buildtest-ios
$ cd /tmp/buildtest-ios
$ phonegap -V build ios
[phonegap] detecting iOS SDK environment...
[phonegap] Checking iOS requirements...
[phonegap] using the local environment
[phonegap] compiling iOS...
[phonegap] Generating config.xml from defaults for platform "ios"
[phonegap] Compiling app on platform "ios" via command "/private/tmp/buildtest-ios/platforms/ios/cordova/build"
[error] An error occurred while building the ios project.** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Ld …Run Code Online (Sandbox Code Playgroud) 我从我的AVCaptureSession获得了一个CVImageBufferRef,我想把这个图像缓冲区并通过网络上传.为了节省空间和时间,我想这样做而不将图像渲染成CIImage和NSBitmapImage,这是我到处看到的解决方案(就像这里:我如何从CVImageBuffer对象获取原始数据).
这是因为我的印象是CVImageBuffer可能会被压缩,这对我来说很棒,如果我渲染它,我必须将其解压缩成一个完整的位图,然后上传整个位图.我想获取压缩数据(意识到单个压缩帧可能在以后自身无法实现),就像它位于CVImageBuffer中一样.我想这意味着我想要CVImageBuffer的基本数据指针及其长度,但它似乎没有办法在API中获得它.有人有什么想法吗?
较新的OpenCV的文档在这里说,你可以将IplImage结构转换为numpy的阵列,就像这样:
arr = numpy.asarray( im )
Run Code Online (Sandbox Code Playgroud)
但这不适合我的需要,因为它显然不支持数学:
x = arr/0.01
TypeError: unsupported operand type(s) for /: 'cv2.cv.iplimage' and 'float'
Run Code Online (Sandbox Code Playgroud)
如果我尝试指定数据类型,我甚至无法做到这一点:
arr = numpy.asarray( im, dtype=num.float32 )
TypeError: float() argument must be a string or a number
Run Code Online (Sandbox Code Playgroud)
所以我使用的是旧文档中提供的代码在这里.基本上,它这样做:
arr = numpy.fromstring( im.tostring(), dtype=numpy.float32 )
Run Code Online (Sandbox Code Playgroud)
但这个tostring电话真的很慢,也许是因为它正在复制数据?我需要这个转换非常快,而不是复制它不需要的任何缓冲区.我不认为数据本质上是不兼容的; 我首先创建了我的IplImage cv.fromarray,这非常快,并且被OpenCV函数接受.
有没有办法可以让新asarray方法为我工作,否则我可以以numpy.fromstring接受它的方式直接访问IplImage中的数据指针吗?我正在使用OpenCV 2.3.1预先打包用于Ubuntu Precise.
我有一个user_photos启用了Facebook 权限的应用.问题是,如果我去Facebook并删除应用程序,iOS不会注意到这一点.ACAccountStore说我有权限,所以requestAccess...返回"授予",但是一旦我尝试了SLRequest,我就会得到一个错误Error validating access token: User XXXXX has not authorized application YYYYY,并且应用程序不再出现在Facebook上.
解决方法是转到设备上的"设置" - >"Facebook",然后关闭并重新启用我的应用程序的权限.下次我尝试requestAccess,我被要求再次确认访问,然后应用程序重新安装在Facebook,一切正常.
ACAccountStore *accountStore = [[[ACAccountStore alloc] init] autorelease];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[accountStore requestAccessToAccountsWithType:accountType
options:@{ACFacebookAppIdKey: kFacebookAppID,
ACFacebookPermissionsKey: @[@"user_photos"]}
completion:^(BOOL granted, NSError *error)
{
if( error ) {
NSLog( @"account permission error %@", error );
}
else if( granted ) {
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me/albums"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:requestURL
parameters:[NSMutableDictionary …Run Code Online (Sandbox Code Playgroud)