加那么些断点完全不须求动一下鼠标(恕小编吹牛B了永利网上娱乐),4.总括字符串的冲天

1.什么样快速的查阅一段代码的实行时间。

#define TICK   NSDate *startTime = [NSDate date]
#define TOCK   NSLog(@"Time: %f", -[startTime timeIntervalSinceNow])

在想要查看执行时间的代码的地点进行那样处理

TICK
//do your work here
TOCK

1.颜色转变成图片

2.怎么高效查看一个函数的调用次数,且不添加一句代码。 如下图

永利网上娱乐 1

look Hitcount

那种艺术适合于二个if方法,二个for循环,而且不会暂停程序,切不供给加一句代码。可是一定要记得选中下边包车型客车automatically
continue after evaluting actions;

3.在选用view的缩放的时候,layer.border.width随着view的松手,会现出锯齿化的题材,化解那几个标题亟需设置这么些性格。

self.layer.allowsEdgeAntialiasing = YES;

- (UIImage *)createImageWithColor:(UIColor *)color
{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
}

2.app评分跳转

4.instrument中time profile 中的self, #self,%self各代表如何 ?

永利网上娱乐 2

self

上边引用了一晃网上的具体内容

Self is “The number of times the symbol calls itself.” according to
the Apple Docs on the Time Profiler.

From the way the numbers look though, it seems self is the summed
duration of samples that had this symbol at the bottom of its stack
trace. That would make:

self: the number of samples where this symbol was at the bottom of the
stack trace
% self: the percent of self samples relative to total samples of
currently displayed call tree
(eg – #self / total samples).
So this wouldn’t tell you how many times a method was called. But it
would give you an idea how much time is spent in a method or lower in
the call tree.

-(void)goToAppStore
{
    NSString *str = [NSString stringWithFormat:
                     @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",547203890];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}

6.什么样飞速添加二个大局11分断点,(一步顶仨步)。和添加一个symbloic断点,(一步如故顶仨步)添加一个断点不接纳鼠标

永利网上娱乐 3

add breakPoint

看看图了吧,加这几个断点完全不供给动一下鼠标(恕我吹牛B了),加单独断点的时候动了下鼠标,但那是自家有意让你们看看本身是有鼠标的。

  • 首先All Exception断点是我们很常用的,那么些本人是如此用八个快速键做到的!通过改键command +p
    为加十一分断点的,要说怎么改,翻自家原先博客去!
  • 下一场加symbloic的快速键为commnamd + option + \
  • 加三个独门一行断点的连忙键为command + \

好呢,就说这一个吗,方今准备把xVim搞熟知,什么鼠标,触摸板统统都走开!

3.收获当前系统语言环境

NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defs objectForKey:@"AppleLanguages"];
NSString *preferredLang = [languages objectAtIndex:0];

4.计算字符串的中度

NSString *str = @"chuanzhang";
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
NSDictionary *dicAtt = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15],NSFontAttributeName,paragraphStyle.copy,NSParagraphStyleAttributeName, nil];
NSAttributedString *attribute = [[NSAttributedString alloc]initWithString:str attributes:dicAtt];
CGRect frame = [attribute boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil];

5.强行关闭app的章程

// 私有API
[[UIApplication sharedApplication] performSelector:@selector(terminateWithSuccess)];
// C语言方法
exit(0);

6.如何赶快的查看一段代码的实施时间

#define TICK   NSDate *startTime = [NSDate date]
#define TOCK   NSLog(@"Time: %f", -[startTime timeIntervalSinceNow])
// 在想要查看执行时间的代码的地方进行这么处理
TICK
//do your work here
TOCK

7.在使用view的缩放的时候,layer.border.width随着view的推广,会冒出锯齿化的题材,消除那几个标题亟需安装那天个性。

self.layer.allowsEdgeAntialiasing = YES;

8.instrument中time profile 中的self, #self,%self各代表怎样 ?

333.jpeg

上边引用了一下网上的具体内容

Self is “The number of times the symbol calls itself.” according to
the Apple Docs on the Time Profiler.

From the way the numbers look though, it seems self is the summed
duration of samples that had this symbol at the bottom of its stack
trace. That would make:

self: the number of samples where this symbol was at the bottom of the
stack trace

% self: the percent of self samples relative to total samples of
currently displayed call tree

(eg – #self / total samples).
So this wouldn’t tell you how many times a method was called. But it
would give you an idea how much time is spent in a method or lower in
the call tree.

9.神器总括图片地方的函数:AVMakeRectWithAspectRatioInsideRect()
透过那几个函数,大家能够总计贰个图纸放在另2个 view
根据一定的百分比居中展现,或许说的本身相比空虚,依旧用图来体现,可以说它能够直接一个image 以其余的百分比展现展现在 imageview 中居中所处的任务,拿
UIViewContontAspectFit来演示

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 300, 300)];
imageView.center = self.view.center;
imageView.backgroundColor = [UIColor redColor];
imageView.contentMode = UIViewContentModeScaleAspectFit;
UIImage *image = [UIImage imageNamed:@"mm.jpg"];
imageView.image = image;

 CGRect iamgeAspectRect = AVMakeRectWithAspectRatioInsideRect(image.size, imageView.bounds);
NSLog(@"iamgeAspectRect = %@, imageView =%@",NSStringFromCGRect(iamgeAspectRect),NSStringFromCGRect(imageView.frame));
[self.view addSubview:imageView];

图片展现如下:

mm.png

log 打因结果如下:

iamgeAspectRect = {{37.563884156729145, 0}, {224.87223168654171, 300}}, imageView ={{37.5, 183.5}, {300, 300}}

能够从 log 得出 对应的 image 以 aspectFit 的不二法门在 imageView 的职分,在
imageView
中的地方是(37.5,0)。那样你平素不须求此外多的代码来测算了。(ps:那几个函数是在
AV框架的,童鞋们自行导入。)

现实它的其余的功利,假设你是做相机或然图片处理的您就明白它的好处了,什么处理横屏照片了,16:9,1:1,4:3图形在控件中的地方,控件上的点对应图片上的点的职位拉,等等。

10.有关
借使三个矩形即使做了平移旋转缩放等一名目繁多操作之后,上下左右的多个点(甚至矩形上自由叁个点)的职位。

CGPoint originalCenter = CGPointApplyAffineTransform(_mStyleLeftEyeView.center,
                                                     CGAffineTransformInvert(_mStyleLeftEyeView.transform));

//1左眼内眼角
CGPoint bottomRight = originalCenter;
bottomRight.x += _mStyleLeftEyeView.bounds.size.width / 2;
bottomRight.y += _mStyleLeftEyeView.bounds.size.height / 2;
bottomRight = CGPointApplyAffineTransform(bottomRight, _mStyleLeftEyeView.transform);

首先那几个 styleLeftView 便是3个矩形的
view,这里以右下角的点做示范,做无论做了其余的 tranform
之后都能够获得它的点的职分
11.tableViewCell上的button,点击获取所在row

UITableViewCell *cell = (UITableViewCell *)[[btn superview] superview];
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];

12.设置粘贴内容

[UIPasteboard generalPasteboard].string = @"string";
// 获取粘贴内容
 NSString *string = [UIPasteboard generalPasteboard].string;

13.魅族为了省去电力所以有三个机关休眠机制,假若想让我们的APP不自动进入休眠只必要设置
UIApplication的idleTimerDisabled 属性为 YES 即可。(切勿滥用)
示例:

[UIApplication sharedApplication].idleTimerDisabled = YES;

14.UIApplicationUserDidTakeScreenshotNotification通告,当用户截屏时接触

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenCapture) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
- (void)screenCapture{
    // doSomething
}

相关文章