哪个是从webview获取HTML代码的最简单方法?我已经尝试了stackoverflow和google的几种方法,但找不到确切的方法.请提一下确切的方法.
public class htmldecoder extends Activity implements OnClickListener,TextWatcher
{
TextView txturl;
Button btgo;
WebView wvbrowser;
TextView txtcode;
ImageButton btcode;
LinearLayout llayout;
int flagbtcode;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.htmldecoder);
txturl=(TextView)findViewById(R.id.txturl);
btgo=(Button)findViewById(R.id.btgo);
btgo.setOnClickListener(this);
wvbrowser=(WebView)findViewById(R.id.wvbrowser);
wvbrowser.setWebViewClient(new HelloWebViewClient());
wvbrowser.getSettings().setJavaScriptEnabled(true);
wvbrowser.getSettings().setPluginsEnabled(true);
wvbrowser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
wvbrowser.addJavascriptInterface(new MyJavaScriptInterface(),"HTMLOUT");
//wvbrowser.loadUrl("http://www.google.com");
wvbrowser.loadUrl("javascript:window.HTMLOUT.showHTML('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');");
txtcode=(TextView)findViewById(R.id.txtcode);
txtcode.addTextChangedListener(this);
btcode=(ImageButton)findViewById(R.id.btcode);
btcode.setOnClickListener(this);
}
public void onClick(View v)
{
if(btgo==v)
{
String url=txturl.getText().toString();
if(!txturl.getText().toString().contains("http://"))
{
url="http://"+url;
}
wvbrowser.loadUrl(url);
//wvbrowser.loadData("<html><head></head><body><div style='width:100px;height:100px;border:1px red solid;'></div></body></html>","text/html","utf-8");
}
else if(btcode==v)
{
ViewGroup.LayoutParams params1=wvbrowser.getLayoutParams();
ViewGroup.LayoutParams params2=txtcode.getLayoutParams();
if(flagbtcode==1)
{
params1.height=200;
params2.height=220;
flagbtcode=0;
//txtcode.setText(wvbrowser.getContentDescription()); …Run Code Online (Sandbox Code Playgroud) 我的应用程序需要与不同的操作系统版本兼容.
如何检测特定类是否可用于特定操作系统?
例如,NSPopover仅在Lion及以上版本中可用,因此如果NSPopover该人使用Snow Leopard ,如何检查操作系统是否支持?
我阅读了http://code.google.com/speed/page-speed/docs/caching.html.它说代理服务器可以缓存cookie.我需要澄清一下.
假设我的文件有这个标题:Cache-Control "max-age=604800, public"
Q.1.使用此标头,当访问静态文件时,来自个人计算机的cookie是否会缓存在代理服务器上?(然后,下一个访问该文件的人会拿起另一个人的饼干吗?)
现在,让我们说缓存代码就像Cache-Control "max-age=7200, proxy-revalidate".
Q.2.就代理服务器上的cookie缓存而言,有什么区别?
现在我对实际设置 cookie的文件(例如Javascript或PHP)有疑问.
Q.3.访问这些类型的文件时,cookie是否会缓存在代理服务器上?或者缓存与静态文件相同?
如果你想知道,我问这些事情的原因是因为我没有一个人的cookie被代理缓存,因此转移到另一个人.所以任何澄清都会有所帮助.非常感谢!
编辑:
非常感谢您的帮助.但我还需要一点澄清.
如果我有使用标题的文件Cache-Control "max-age=604800, public",是否会将任何请求cookie(Cookie)或响应cookie(Set-Cookie)转移到另一个用户的计算机(因为它在缓存中)?或者它是否仅针对该用户的浏览进行缓存?如果设置是Cache-Control "max-age=7200, proxy-revalidate"什么?再次感谢.
我已经使用Safari的"保持+保存图像"选项将一些图片存储到模拟器中的照片库中.当我从库中选择图像时,我必须将其转换为JPEG或PNG,以便将其上传到服务器.问题是原始图像的大小约为200 KB,但转换为PNG后的图像大约为2 MB.我正在使用UIImagePNGRepresentation将UIImage对象转换为NSData然后发布图像.
我在这里错过了什么?为什么图片的大小会比原始大小大?我怎么能阻止这个?
UIImageJPEGRepresentation和之间有什么区别UIImagePNGRepresentation?应该使用哪一个(推荐)?
我可以确定从照片库加载的图像类型吗?
iPhone相机拍摄的默认图像类型是什么?
我有一个基于核心数据的应用程序来管理一堆实体.我希望能够做到以下几点.
我有一个实体"SomeEntity",其属性包括:name,type,rank,foo1,foo2.
现在,如果我们严格用SQL术语来说,SomeEntity有几行.我想要完成的是只检索可用的类型,即使每个实例都有重复的类型.我也需要他们按顺序返回.所以在SQL中,我正在寻找的是以下内容:
SELECT DISTINCT(type) ORDER BY rank ASC
这是我到目前为止破坏的代码:
NSError *error = NULL;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setReturnsDistinctResults:YES];
[fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:@"type", @"rank", nil]];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"SomeEntity" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
// sort by rank
NSSortDescriptor *rankDescriptor = [[NSSortDescriptor alloc] initWithKey:@"rank" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:rankDescriptor,nil];
[fetchRequest setSortDescriptors:sortDescriptors];
[sortDescriptors release];
[rankDescriptor release];
NSArray *fetchResults = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
[fetchRequest release];
return fetchResults;
Run Code Online (Sandbox Code Playgroud)
现在崩溃了以下: Invalid keypath section passed to setPropertiesToFetch:
我有一个问题,使用Javascript FileRead尝试读取大文件.
例如,我有一个200mb的文本文件,每次我读这个文件代码停止工作.
它可以读取文本文件,但是例如只有前10行或10mb后停止读取?
这是我的代码:
var file = form.getEl().down('input[type=file]').dom.files[0];
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
data = e.target.result;
form.displayedData=data;
};
})(file);
reader.readAsText(file);
Run Code Online (Sandbox Code Playgroud)
该e.target.result总是有文件的全部数据.
我能在这做什么?
谢谢
我的查询如下所示:
SELECT COUNT(entryID)
FROM table
WHERE date >= DATE_SUB(CURDATE(), INTERVAL 1 DAY)
Run Code Online (Sandbox Code Playgroud)
这会计算其date值在一天内的行(从12:00开始;不在24小时内)吗?如果没有,我该怎么办?
来自Stripe文档:
当您取消订阅时,客户的卡不会再次收费,但也不会退还任何款项.如果您想要退款,可以通过Stripe的信息中心或API进行退款.
我创建了每月订阅,我只想退还订阅月份内尚未过去的天数.如何使用Stripe API仅退还订阅中尚未完成的天数?
我需要知道用户是否在跳板设置中更改了系统时间.因此我的后台程序可以得到通知.根据文件,NSSystemClockDidChangeNotification是一个选择.但我不能收到任何东西:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleSysTimeChanged:)
name:NSSystemClockDidChangeNotification
object:nil];
Run Code Online (Sandbox Code Playgroud)
我哪里错了?有什么建议?
如何为Core Data(iOS7)添加启用和禁用iCloud同步的选项?
以下是我的想法/尝试:
要禁用iCloud同步:
NSDictionary *options = @{NSPersistentStoreUbiquitousContentNameKey: @"MYStore"};
[NSPersistentStoreCoordinator removeUbiquitousContentAndPersistentStoreAtURL:storeUrl options:options error:&error];
Run Code Online (Sandbox Code Playgroud)
但是,我认为这可能会删除iCloud中的所有数据?我不希望这样.
要启用iCloud同步:
NSDictionary *options = @{NSPersistentStoreUbiquitousContentNameKey: @"MYStore"};
[__persistentStoreCoordinator lock];
result = [__persistentStoreCoordinator migratePersistentStore:result toURL:storeUrl options:options withType:NSSQLiteStoreType error:&error];
[__persistentStoreCoordinator unlock];
Run Code Online (Sandbox Code Playgroud)
在此代码中,我尝试options使用NSPersistentStoreUbiquitousContentNameKey密钥添加,以便它开始与iCloud同步.但是,我不想将商店移到新的位置.这段代码合适吗?
如何在应用程序运行时启用/禁用iCloud?