我有一个应用程序,我将内容加载到一个UIWebView
并呈现此.我无法完全禁用用户交互,因为我希望用户能够单击链接.我只需要禁用用户选择.我发现你可以使用的互联网中的某个地方:
document.body.style.webkitUserSelect='none';
Run Code Online (Sandbox Code Playgroud)
我试着插入这个
[self.contentView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitUserSelect='none';"];
Run Code Online (Sandbox Code Playgroud)
在 webViewDidFinishLoad:
但是,它不起作用.我仍然可以在WebView中选择和复制文本.
什么想法可能会出错?
更新:这似乎只从iOS 4.3开始
有没有办法通过HTTP请求检查AppStore中的名称是否可用?无需在iTunes Connect中手动创建应用程序?
我有以下内容:
<%= link_to "Exhibitions", :action => 'tabExhibitions', :id => @app.id, :remote => true %>
Run Code Online (Sandbox Code Playgroud)
它产生:
<div class="tabbarButton" id="tabbarExhibitions">
<a href="/apps/3/tabExhibitions?remote=true">Exhibitions</a>
</div>
Run Code Online (Sandbox Code Playgroud)
单击时会导致共同的GET请求.
我是Rails的新手但我的理解是设置:remote => true
应该创建一个<a href="..." data-remote=true>
而不是一个普通的链接.
我正在使用jQuery,必要的标头和元标签已经到位.我应该提到这个项目是从Rails 2.3.8升级而来的
谢谢你的帮助.
我有一个模型对象,它是ActiveRecord的子类.此外,使用STI,我定义了此对象的子类,它定义了不同的类型和行为.结构看起来像这样:
class AppModule < ActiveRecord::Base
belongs_to :app
end
class AppModuleList < AppModule
end
class AppModuleSearch < AppModule
end
class AppModuleThumbs < AppModule
end
Run Code Online (Sandbox Code Playgroud)
现在,在用户可以选择创建新AppModule的视图中,我希望他们从下拉菜单中进行选择.但是我无法使用subclasses()方法获取AppModule的子类列表:
<% form_for(@app_module) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :type %><br />
<%= f.select(:type, options_from_collection_for_select(@app_module.subclasses().map{ |c| c.to_s }.sort)) %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我明白了:
NoMethodError: undefined method `subclasses' for #<AppModule:0x1036b76d8>
Run Code Online (Sandbox Code Playgroud)
我很感激任何帮助.非常感谢!
我将一些下载的信息缓存在应用程序的NSLibraryDirectory中.但是,在最近的更新之后,用户报告在访问Library目录中先前下载的内容时遇到问题.
哪些目录可以安全地在新的应用程序版本上缓存信息?有关于此的Apple文档吗?我找不到任何......
非常感谢,e.
我正在努力使现有的iPhone/iPad项目向后兼容到iPhoneOS 3.0.
我目前的测试设备是带有3.1.3的iPod Touch.
以下代码导致问题:
Class gestureRecognizer = NSClassFromString(@"UISwipeGestureRecognizer");
if (gestureRecognizer != nil)
{
UISwipeGestureRecognizer * leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(didSwipeLeft:)];
leftSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
leftSwipeRecognizer.delegate = self;
[self.view addGestureRecognizer:leftSwipeRecognizer];
_leftSwipeRecognizer = leftSwipeRecognizer;
}
Run Code Online (Sandbox Code Playgroud)
根据Apple文档,UIGestureRecognizer是从iOS 3.2开始定义的.因此,我希望Class gestureReconizer
是nil
在以前的操作系统版本及以下,如果被跳过.但它不会跳过.gestureRecognizer
不是nil
,if
开始执行和崩溃的代码,leftSwipeRecognizer.direction
因为:
-[UISwipeGestureRecognizer setDirection:]: unrecognized selector sent to instance 0x1e5720
Run Code Online (Sandbox Code Playgroud)
这种情况非常令人困惑.我想我正在做这本书的一切.我尝试在使用它之前检查一个类是否存在,但是那个不应该存在的类就在那里,愚弄我的测试,不符合它的预期规格和崩溃.
我当然可以respondsToSelector
在这里和那里做一些检查以解决这个崩溃,但这不是一个优雅的方法.
还有其他建议吗?
我有一个应用程序,当用户首次启动应用程序时,它会显示自定义的无数据单元格.
当用户进行第一个条目时,我的fetchedResultsController的fetchedResults会更新,这会导致删除无数据单元格并插入数据单元格.
这曾经在过去工作(iPhone 3.x).现在在iOS 4.2上,它会在调用endUpdates后导致崩溃.没有异常信息或任何可理解的堆栈跟踪.我只知道崩溃是在_CFTypeCollectionRetain中引起的(可能试图保留NULL)
任何想法如何进行?
这是相关代码:
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
NSLog(@"starting updates");
[self.tableView beginUpdates];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
switch(type) {
case NSFetchedResultsChangeInsert:
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
}
}
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath {
UITableView *tv = self.tableView;
[tv reloadData];
switch(type) {
case NSFetchedResultsChangeInsert:
NSLog(@"insert");
if ([self.tableView numberOfRowsInSection:newIndexPath.section] == 1 &&
[[self.fetchedResultsController fetchedObjects] count] == 1)
{
NSLog(@"reloading row %d", newIndexPath.row);
[tv …
Run Code Online (Sandbox Code Playgroud) 根据文档建议在POST请求中设置privacy
为SECRET
不起作用.我通过自己的代码和Graph API Explorer尝试了这两种方法.创建的事件始终是公开的.
这根本不受支持还是我做错了什么?
我有一个UIWebView
显示静态内容并通过其控制器对各种滑动手势作出反应.
文本选择已被禁用,但现在我正在开发一个新功能,允许文本选择并显示自定义上下文菜单.
现在我需要能够检测文本选择何时处于活动状态,以便我可以关闭滑动手势.
我能想到的唯一方法是在滑动处理程序方法中检查是否使用JS选择了文本.还有其他想法吗?有人知道怎么做得更好吗?
谢谢.
我刚刚开始学习rails和ruby,所以如果这太愚蠢了,请耐心等待.
我的应用程序中有几种不同的AppModule类型,它们具有不同的行为但数据类似,所以我使用单表继承来保存它们.
但是,当尝试允许用户明确选择他们想要的类型时,app_modules/new.html.erb
我会收到警告WARNING: Can't mass-assign these protected attributes: type
.这是相关代码:
<% form_for(@app_module) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :type %><br />
<%= f.select( :type, options_from_collection_for_select(AppModule.subclasses().map{ |c| c.name}, 'to_s', 'to_s')) %>
</p>
<%= f.submit 'Create' %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我已尝试attr_accessible :type
在模型文件中明确设置但它不起作用
我使用的是rails 2.3.8和ruby 1.8.7.
任何帮助非常感谢,谢谢......
ios ×6
app-store ×2
ruby ×2
uiwebview ×2
ajax ×1
core-data ×1
events ×1
facebook ×1
inheritance ×1
inspect ×1
ios4 ×1
iphone ×1
itunes ×1
javascript ×1
localization ×1
meteor ×1
reflection ×1
uitableview ×1
webkit ×1