白羽
2018-11-23
来源 :网络
阅读 1291
评论 0
摘要:本文将带你了解IOS开发入门iOS - 开发,希望本文对大家学IOS有所帮助。
本文将带你了解IOS开发入门iOS - 开发,希望本文对大家学IOS有所帮助。
1. Xcode在真机调试的时候出现”The identity used to sign the executable is no longer valid”
解决方案:
(1)provisioning Profile文件选择错误
(2)provisioning Profile已失效
(3)开发者证书过期或者被删除了
2. 将storyBoard里的控制器进行实例化
注:需要在Storyboard里面设置控制器的Storyboard ID
//Identifier:@“Storyboard ID”
//将storyBoard实例化 (1)(可以在AppDelegate里面使用)
UIStoryboard *mainSB = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//将要跳转控制器通过storyBoard实例化
ViewController *VC = [mainSB instantiateViewControllerWithIdentifier:@"ViewController"];
VC.isModifyPassword = NO;
[self.navigationController pushViewController:VC animated:YES];
//将storyBoard实例化 (2)
//将要跳转控制器通过storyBoard实例化
ViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
VC.isModifyPassword = NO;
[self.navigationController pushViewController:VC animated:YES];
3. 仿安卓Toast
#import <foundation foundation.h="">
#import <uikit uikit.h="">
//声明定义一个ToastLabel对象
@interface ToastLabel : UILabel
- (void)setMessageText:(NSString *)text;
@end
@interface Toast : NSObject
{
ToastLabel *toastLabel;
NSTimer *countTimer;
NSInteger changeCount;
}
//创建声明单例的方法
+ (instancetype)shareInstance;
- (void)makeToast:(NSString *)message duration:(CGFloat )duation;
@end
#import "Toast.h"
@implementation ToastLabel
/**
* ToastLabel初始化,位label设置各种属性
*
* @return ToastLabel
*/
- (instancetype)init{
self = [super init];
if (self) {
self.layer.cornerRadius = 10;
self.layer.masksToBounds = YES;
self.backgroundColor = [UIColor blackColor];
self.numberOfLines = 0;
self.textAlignment = NSTextAlignmentCenter;
self.textColor = [UIColor whiteColor];
self.font = [UIFont systemFontOfSize:15];
}
return self;
}
/**
* 设置显示的文字
*
* @aram text 文字文本
*/
- (void)setMessageText:(NSString *)text{
[self setText:text];
CGRect rect = [self.text boundingRectWithSize:CGSizeMake(DeviceWidth - 20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:self.font} context:nil];
CGFloat width = rect.size.width + 20;
CGFloat height = rect.size.height + 20;
CGFloat x = (DeviceWidth - width) / 2;
CGFloat y = DeviceHight - height - 80;
self.frame = CGRectMake(x, y, width, height);
}
@end
@implementation Toast
/**
* 实现声明单例的方法 GCD
*
* @return 单例
*/
+ (instancetype)shareInstance{
static Toast *singleton = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
singleton = [[Toast alloc] init];
});
return singleton;
}
/**
* 初始化方法
*
* @return 自身
*
*/
- (instancetype)init{
self = [super init];
if (self) {
toastLabel = [[ToastLabel alloc] init];
countTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(changeTime) userInfo:nil repeats:YES];
countTimer.fireDate = [NSDate distantFuture];//关闭定时器
}
return self;
}
/**
* 弹出并显示Tosat
*
* @param message 显示的文本内容
* @param duration 显示时间
*/
- (void)makeToast:(NSString *)message duration:(CGFloat)duation{
if ([message length] == 0) {
return;
}
[toastLabel setMessageText:message];
[[[UIApplication sharedApplication]keyWindow ] addSubview:toastLabel];
toastLabel.alpha = 0.8;
countTimer.fireDate = [NSDate distantPast];//开启定时器
changeCount = duation;
}
/**
* 定时器回调方法
*/
- (void)changeTime{
//NSLog(@"时间:%ld",changeCount);
if (changeCount-- <= 0) {
countTimer.fireDate = [NSDate distantFuture];//关闭定时器
[UIView animateWithDuration:0.2f animations:^{
toastLabel.alpha = 0;
} completion:^(BOOL finished) {
[toastLabel removeFromSuperview];
}];
}
}
@end
//duration:显示的时长
[[Toast shareInstance] makeToast:@"你提示的内容" duration:1.0];
</uikit></foundation>
4. UITextField的左视图设置
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之IOS频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号