我尝试了几个小时用CAShapeLayer在我的UIView周围画一个虚线边框,但是我没有显示它.
ScaleOverlay.h
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@interface ScaleOverlay : UIView <UIGestureRecognizerDelegate> {
CAShapeLayer *shapeLayer_;
}
@end
Run Code Online (Sandbox Code Playgroud)
ScaleOverlay.m
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor redColor];
self.alpha = 0;
//Round corners
[[self layer] setCornerRadius:8.f];
[[self layer] setMasksToBounds:YES];
//Border
shapeLayer_ = [[CAShapeLayer layer] retain];
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, frame);
shapeLayer_.path = path;
CGPathRelease(path);
shapeLayer_.backgroundColor = [[UIColor clearColor] CGColor];
shapeLayer_.frame = frame;
shapeLayer_.position = self.center;
[shapeLayer_ setValue:[NSNumber numberWithBool:NO] forKey:@"isCircle"];
shapeLayer_.fillColor = [[UIColor blueColor] CGColor];
shapeLayer_.strokeColor …Run Code Online (Sandbox Code Playgroud) 我正在使用Python 2.7.9.Win7 x64上的x32.
当我记录包含变音符号的异常时,我总是收到
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 39: ordinal not in range(128)
我的示例代码是:
except Exception as e:
logging.error('Error loading SCMTool for repository '
'%s (ID %d): %s' % (repo.name, repo.id, e),
exc_info=1)
Run Code Online (Sandbox Code Playgroud)
记录的异常是WindowsError: [Error 267] Der Verzeichnisname ist ungültig.这个问题是基于"UNG Ü LTIG"变音.
删除最后一个后%s,e它没有问题.
每次记录异常时都会发生这种情况,因此无法替换每个记录器.
有没有人知道如何让Exception在全局范围内返回一个unicode字符串?
我不想将比例用作经典缩放,而是我想将quadrates的形式更改为矩形.经过大量的尝试,我的手指是长方形的角落.所以,但如果我在我的视图中开始一个新的捏手势,我的手指变小,而不是像正常的尺度那样变大.
if ([gestureRecognizer numberOfTouches] >1) {
//getting width and height between gestureCenter and one of my finger
float x = [gestureRecognizer locationInView:self].x - [gestureRecognizer locationOfTouch:0 inView:self].x;
if (x<0) {
x *= -1;
}
float y = [gestureRecognizer locationInView:self].y - [gestureRecognizer locationOfTouch:0 inView:self].y;
if (y<0) {
y *= -1;
}
//double size cause x and y is just the way from the middle to my finger
float width = x*2;
if (width < 1) {
width = 1;
}
float height …Run Code Online (Sandbox Code Playgroud) 我的问题是,我需要找到包含所有白色像素的cv :: Mat图像的子矩阵.因此,我想遍历所有像素,检查它们是否为白色并使用该信息构建cv :: Rect.
我想出了如何迭代所有像素,但我不知道如何从中获取像素颜色.之前将cv :: Mat转换为灰度CV_GRAY2BGR
for(int y = 0; y < outputFrame.rows; y++)
{
for(int x = 0; x < outputFrame.cols; x++)
{
// I don't know which datatype I should use
if (outputFrame.at<INSERT_DATATYPE_HERE>(x,y) == 255)
//define area
}
}
Run Code Online (Sandbox Code Playgroud)
我的最后一个问题是,我应该在位置INSERT_DATATYPE_HERE的代码中插入哪种数据类型,并且255是与之比较的正确值?
非常感谢
我使用UIView子类与其他视图的NSMutableArray来指示值为条形.
我在initWithFrame中初始化它.仪器告诉我创建和删除我的UIView子类后,NSMutableArray的alloc有一个泄漏.
这就是为什么我用if框架它以避免多个对象.但没有帮助
- (id) initWithFrame :(CGRect)frame
{
self = [super initWithFrame:frame];
if (self.uiValueSubviews == nil){
self.uiValueSubviews = [[NSMutableArray alloc]init];
}
return self;
}
- (void)dealloc {
[self.uiValueSubviews release];
[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
我对dealloc做错了吗?
谢谢你的帮助
iphone ×3
objective-c ×2
colors ×1
ios ×1
logging ×1
matrix ×1
memory-leaks ×1
opencv ×1
pinch ×1
pixel ×1
python ×1
python-2.7 ×1
scale ×1
unicode ×1