我有一个锚标签如下:
<a href="#map_4D85448A3D4C4180A02BD6FC387ABC45" onclick="jumptosection('map_4D85448A3D4C4180A02BD6FC387ABC45');">A Guide</a>
Run Code Online (Sandbox Code Playgroud)
它导航到 ID 为“map_4D85448A3D4C4180A02BD6FC387ABC45”的部分。jumptosection函数如下:
function jumptosection(id) {
var target = document.getElementById(id);
if(document.all){
document.documentElement.scrollTop = target.offsetTop;
}else{
var top = 0;
do {
top += target.offsetTop || 0;
target = target.offsetParent;
} while(target);
document.body.scrollTop = top ;
}
//$('#article').css.paddingTop = '55px';
return false;
Run Code Online (Sandbox Code Playgroud)
但即使我在这个函数中什么都不写,行为仍然是一样的。问题是我有一个 92px 的标题条,当我点击给定的锚点时,它隐藏了该部分的某些部分。如何在添加一些像素以转义标题的同时使其滚动到给定部分?
我有一个CGImageRef,我想转换为NSData而不将其保存到某个文件中.现在,我通过将图像保存到某个临时位置然后将其检索到NSData来执行此操作.如何在不保存图像的情况下执行此操作?
CGImageRef img = [[self system_Application] getScreenShot];
NSString *tempDirectory = NSTemporaryDirectory();
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/abc.jpg",tempDirectory]];
CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL);
CGImageDestinationAddImage(destination, img, nil);
if(!CGImageDestinationFinalize(destination))
NSLog(@"Failed to write Image");
NSData *mydata = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/abc.jpg",tempDirectory]];
Run Code Online (Sandbox Code Playgroud)