是否有一种方便的方法来格式化一个相当长的字符串,其中包含段落(如下所示)以便在其中使用\n它,因此textView也会显示段落?
blah
blah
Run Code Online (Sandbox Code Playgroud)
至 @"blah\n\nblah"
谢谢!
我有一些 z=f(x,y) 数据,我想在热图中显示。所以我用来np.meshgrid创建一个 (x,y) 网格,然后调用pcolormesh. 然而,与数据点相对应的每个“图块”的刻度并不居中——在文档中,我没有找到任何关于如何将每个图块的刻度居中的说明,以便我可以立即读出相应的值。有任何想法吗?
例如,在所附图像中,不清楚该刻度对应于哪个 x 值。
在iPad上,textFieldShouldReturn不再有效.我让它工作到五分钟前,突然间这个方法不再被调用了...任何想法?下面是代码,唯一改变的是UITextView的通知......谢谢!
- (BOOL)textFieldShouldReturn:(UITextField *)tf
{
NSString* newName = textField.text;
textLabel.text = textField.text;
NSLog(@"Called!");
newName = [newName stringByAppendingPathExtension:@"txt"];
NSString* newPath = [[currentFilePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newName];
NSLog(@"%@",newPath);
[[NSFileManager defaultManager] moveItemAtPath:currentFilePath toPath:newPath error:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"DataSaved" object:nil];
[currentFilePath retain];
currentFilePath = newPath;
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
[currentFilePath retain];
// Write out the contents of home directory to console
NSLog(@"Documents directory: %@", [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil]);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
textLabel.alpha = 1.0;
textField.alpha = 0.0;
[UIView commitAnimations];
[tf resignFirstResponder];
return YES;
Run Code Online (Sandbox Code Playgroud)
}
我想将我的scrollview的屏幕外内容渲染为图像.
但是下面的代码只在屏幕上呈现内容,即使它应该呈现整个scrollView内容.
有人可以提供帮助吗?
提前致谢!
UIImage *image = nil;
UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, false, 0.0);
{
CGPoint savedContentOffset = scrollView.contentOffset;
CGRect savedFrame = scrollView.frame;
scrollView.contentOffset = CGPointMake(0.0, 0.0);
scrollView.frame = CGRectMake(0, 0.0, scrollView.contentSize.width, scrollView.contentSize.height);
NSLog(@"%.2f",scrollView.contentSize.height);
[scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
scrollView.contentOffset = savedContentOffset;
scrollView.frame = savedFrame;
}
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud) ios ×3
ipad ×2
cgcontext ×1
cocoa-touch ×1
heatmap ×1
line-breaks ×1
matplotlib ×1
numpy ×1
objective-c ×1
paragraph ×1
plot ×1
python ×1
render ×1
textfield ×1
uiscrollview ×1
uitextfield ×1