小编Fas*_*ser的帖子

在没有\n的情况下在UITextView中显示段落

是否有一种方便的方法来格式化一个相当长的字符串,其中包含段落(如下所示)以便在其中使用\n它,因此textView也会显示段落?

blah

blah
Run Code Online (Sandbox Code Playgroud)

@"blah\n\nblah"

谢谢!

cocoa-touch objective-c line-breaks paragraph ios

2
推荐指数
1
解决办法
1520
查看次数

pcolormesh 为每个数据点/图块勾选中心

我有一些 z=f(x,y) 数据,我想在热图中显示。所以我用来np.meshgrid创建一个 (x,y) 网格,然后调用pcolormesh. 然而,与数据点相对应的每个“图块”的刻度并不居中——在文档中,我没有找到任何关于如何将每个图块的刻度居中的说明,以便我可以立即读出相应的值。有任何想法吗?

例如,在所附图像中,不清楚该刻度对应于哪个 x 值。

蜱虫

python plot numpy matplotlib heatmap

2
推荐指数
1
解决办法
5042
查看次数

textFieldShouldReturn不再有效

在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)

}

textfield uitextfield ipad ios

0
推荐指数
1
解决办法
3102
查看次数

捕获/渲染Scrollview的屏幕外内容

我想将我的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)

render uiscrollview cgcontext ipad ios

0
推荐指数
1
解决办法
2107
查看次数