我有以下代码来选择input
id="embedurl"
元素的所有内容
$('#embedurl').focus(function(event) {
setTimeout(function() {
$('#embedurl').select();
}, 0);
});
它在桌面上运行良好,但在iOS中没有选择。
我知道如何解决这个问题吗?
谢谢!
答案 0 :(得分:1)
尝试:
-(void)awakeFromNib
{
if( self.titleString )
{
[self.documentTitle setStringValue:self.titleString];
}
}
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
// Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO.
// You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
// If you override either of these, you should also override -isEntireFileLoaded to return NO if the contents are lazily loaded.
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray *array = [string componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
NSLog(@"\r%@", array);
self.titleString = [array objectAtIndex:1];
return YES;
}
来自this回答。它对我有用,虽然对该答案的评论确实注意到一些警告,例如需要首先触发focus()事件。