My First

如有问题请留言「Stay hungry. Stay foolish.」


  • 首页

  • 归档

  • 标签

  • 搜索

问题记录

发表于 2016-03-01 |

如下错误是没有rootViewController,我平时并不这么写

1
2
3
4
5
6
7
8
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.window addSubview:controller.view];
[self.window makeKeyAndVisible];
return YES;
}

错误:

1
2
3
4
5
*** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/UIApplication.m:3315
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
*** First throw call stack:
(0x1821c5900 0x181833f80 0x1821c57d0 0x182b3899c 0x187160ac0 0x18715d5c0 0x18377b790 0x18377bb10 0x18217cefc 0x18217c990 0x18217a690 0x1820a9680 0x186f26580 0x186f20d90 0x1000de108 0x181c4a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

解决方法:

设置rootViewController

1
[self.window setRootViewController:[UIViewController new]];

iOS渐变颜色可设置渐变方向

发表于 2016-03-01 |

参考原文

1
2
3
4
5
6
7
8
9
10
11
12
13
#import <UIKit/UIKit.h>
//渐变方向
typedef NS_ENUM(NSUInteger, GradientType) {
GradientTypeTopToBottom = 0, //从上到小
GradientTypeLeftToRight = 1, //从左到右
GradientTypeUpleftToLowright = 2, //左上到右下
GradientTypeUprightToLowleft = 3, //右上到左下
};
@interface UIImage (GradientColor)
+ (UIImage *)gradientColorImageFromColors:(NSArray *)colors
gradientType:(GradientType)gradientType
imgSize:(CGSize)imgSize;
@end
阅读全文 »

iOS在程序中控制系统的屏幕亮度

发表于 2016-03-01 |

参考原文

1
2
// 0 .. 1.0, where 1.0 is maximum brightness. Only supported by main screen.
@property(nonatomic) CGFloat brightness NS_AVAILABLE_IOS(5_0) __TVOS_PROHIBITED;
1
2
3
4
5
//获取系统屏幕当前的亮度值
CGFloat value = [UIScreen mainScreen].brightness;
//设置系统屏幕亮度值
value += 0.8;
[[UIScreen mainScreen] setBrightness:value];

使用U盘装MAC OS X

发表于 2016-02-29 |

我装的是OS X EI Capitan
有两种方法:
一,网络恢复
必须在能用国外的网的基础上才可以(我是开的vpn),我选择的是第二种方法
二,将U盘设置成启动盘,直接安装
安装的先决条件

  1. 准备一个不小到8G的盘
  2. 将盘插入电脑的usb口中,打开磁盘工具
  3. 将盘抹掉,如下图
  4. 1
阅读全文 »

appleDeveloperAccount 苹果IOS开发者账号

发表于 2016-02-25 |

参考原文

个人账号(Individual):

费用99美金一年, 该账号在App Store销售者只能显示个人的ID,比如zhitian zhang,单人使用。个人账号只能有一个开发者。100个苹果的iOS设备UDID测试。

公司团队账号 (Company/Organization):

费用99美金一年, 该账号在App Store销售者可以显示类似Studios,或者自定义的团队名称
,比如Mamshare INC,公司账号可以允许多个开发者协作开发,比个人多一些帐号管理的设置,可以设置多个AppleID,分4种管理级别权限,详细见备注。100个苹果的iOS设备UDID测试。但是申请时需要填写公司的邓白氏编码(D-U-N-S)。

阅读全文 »

绘制虚线

发表于 2016-02-24 |

参考原文

绘制虚线方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
** lineView: 需要绘制成虚线的view
** lineLength: 虚线的宽度
** lineSpacing: 虚线的间距
** lineColor: 虚线的颜色
**/
+ (void)drawDashLine:(UIView *)lineView
lineLength:(int)lineLength
lineSpacing:(int)lineSpacing
lineColor:(UIColor *)lineColor {
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
[shapeLayer setBounds:lineView.bounds];
[shapeLayer setPosition:CGPointMake(CGRectGetWidth(lineView.frame) / 2,
CGRectGetHeight(lineView.frame))];
[shapeLayer setFillColor:[UIColor clearColor].CGColor];
// 设置虚线颜色为blackColor
[shapeLayer setStrokeColor:lineColor.CGColor];
// 设置虚线宽度
[shapeLayer setLineWidth:CGRectGetHeight(lineView.frame)];
[shapeLayer setLineJoin:kCALineJoinRound];
// 设置线宽,线间距
[shapeLayer
setLineDashPattern:[NSArray
arrayWithObjects:[NSNumber
numberWithInt:lineLength],
[NSNumber
numberWithInt:lineSpacing],
nil]];
// 设置路径
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, CGRectGetWidth(lineView.frame), 0);
[shapeLayer setPath:path];
CGPathRelease(path);
// 把绘制好的虚线添加上来
[lineView.layer addSublayer:shapeLayer];
}

使用

1
2
3
4
[ViewController drawDashLine:self.lineView
lineLength:10
lineSpacing:2.0
lineColor:[UIColor colorWithHexString:@"393939"]];

绘制虚线【竖线】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* 绘制虚线【竖线】
*
* @param lineView 需要绘制成虚线的view
* @param lineLength 虚线的宽度
* @param lineSpacing 虚线的间距
* @param lineColor 虚线的颜色
*/
+ (void)drawDashVerticalLine:(UIView *)lineView
lineLength:(int)lineLength
lineSpacing:(int)lineSpacing
lineColor:(UIColor *)lineColor {
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
[shapeLayer setBounds:lineView.bounds];
[shapeLayer setPosition:CGPointMake(CGRectGetWidth(lineView.frame),
CGRectGetHeight(lineView.frame) * 0.5)];
[shapeLayer setFillColor:[UIColor clearColor].CGColor];
// 设置虚线颜色为blackColor
[shapeLayer setStrokeColor:lineColor.CGColor];
// 设置虚线宽度
[shapeLayer setLineWidth:lineLength];
[shapeLayer setLineJoin:kCALineJoinRound];
// 设置线宽,线间距
[shapeLayer
setLineDashPattern:[NSArray
arrayWithObjects:[NSNumber
numberWithInt:lineLength],
[NSNumber
numberWithInt:lineSpacing],
nil]];
// 设置路径
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, 0, lineView.frame.size.height);
[shapeLayer setPath:path];
CGPathRelease(path);
// 把绘制好的虚线添加上来
[lineView.layer addSublayer:shapeLayer];
}

category下载

十六进制颜色转换成UIColor

发表于 2016-02-24 |

原文出自

interface

1
2
3
@interface UIColor (hex)
+ (UIColor *)colorWithHexString:(NSString *)stringToConvert;
@end

implementation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#import <QuartzCore/QuartzCore.h>
#define DEFAULT_VOID_COLOR [UIColor whiteColor]
@implementation UIColor (hex)
+ (UIColor *)colorWithHexString:(NSString *)stringToConvert {
NSString *cString = [[stringToConvert
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]
uppercaseString];
if ([cString length] < 6)
return DEFAULT_VOID_COLOR;
if ([cString hasPrefix:@"#"])
cString = [cString substringFromIndex:1];
if ([cString length] != 6)
return DEFAULT_VOID_COLOR;
阅读全文 »

capturePicture 截取scrollView和屏幕显示的图片

发表于 2016-02-16 |

一、获取当前屏幕显示的图片

1
2
3
4
UIGraphicsBeginImageContextWithOptions(_scrollView.contentSize, YES, 1);
[_scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *uiImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

二、获取scrollView的contentSize包含的图片

阅读全文 »

sendMail 发邮件

发表于 2016-02-16 |

使用SKPSMTPMessage无需弹框发送邮件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//使用SKPSMTPMessage无需弹框发送邮件
我使用的是
1.导入头文件
#import "NSData+Base64Additions.h"
#import "SKPSMTPMessage.h"
SKPSMTPMessage *mail = [[SKPSMTPMessage alloc] init];
[mail setSubject:@"标题"]; // 设置邮件主题
[mail setToEmail:@".com"]; // 目标邮箱
[mail setFromEmail:@".com"]; // 发送者邮箱
[mail setRelayHost:@"smtp.qq.com"]; // 发送邮件代理服务器
[mail setRequiresAuth:YES];
[mail setLogin:@".com"]; // 发送者邮箱账号
[mail setPass:@""]; // 发送者邮箱密码
[mail setWantsSecure:YES]; // 需要加密
[mail setDelegate:self];
阅读全文 »

D-U-N-S(邓白氏编码)申请

发表于 2016-02-16 |

公司版和企业版的 Apple开发者帐户申请需要您提交邓白氏号码。申请的表格需要您用 英文或拼音填写。
请至 Apple 以下网站以查看贵公司是否已拥有邓白氏编号,如果您有查到任何记录,请确认记录中的公司是否就是贵公司;如果没有查到任何资料或系统调出的记录均不是贵公司的信息,请点击 “Submit Your Information” 提交申请,成功提交至邓白氏公司,他们将会继续协助您获取该编号,申请时间一般需要七个工作日:

申请地址请点击:申请地址

此电话有中文客服
4006701855 : 苹果电话
02126107504 : duns方负责专门负责被拒的电话

邓白氏公司全球支持部门
appdeveloper@dnb.com

各地区 Apple 开发者计划支援电话号码查询

阅读全文 »
1…101112
Irena

Irena

第一个清晨

111 日志
9 标签
Github Weibo
Links
  • 菜天雨
© 2018 Irena
由 Hexo 强力驱动
主题 - NexT.Pisces