日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > 我的文檔

我的文檔

來源:程序員人生   發布時間:2016-09-30 10:45:03 閱讀次數:2748次

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> //聲明定義1個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];

4. UITextField的左視圖設置

//1.創建UITextField種別 #import <UIKit/UIKit.h> @interface loginUITextField : UITextField @end //2.重寫UITextField的左視圖的Bounds #import "loginUITextField.h" @implementation loginUITextField - (CGRect)leftViewRectForBounds:(CGRect)bounds { CGRect rect = [super leftViewRectForBounds:bounds]; if (self.window.frame.size.width == 320) { rect = CGRectMake(rect.origin.x + 3, rect.origin.y , 28, 28); } else if (self.window.frame.size.width == 375){ rect = CGRectMake(rect.origin.x + 4, rect.origin.y , 32, 32); } else { rect = CGRectMake(rect.origin.x + 5, rect.origin.y , 35, 35); } return rect; } @end //以下是例子 其實不能直接使用 //_userTextField的左視圖 UIImageView *useImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user"]]; _userImageView.contentMode = UIViewContentModeScaleAspectFit; _userTextField.leftView = useImageView; _userTextField.leftViewMode = UITextFieldViewModeAlways; _userTextField.borderStyle = UITextBorderStyleRoundedRect; //修改水印字體色彩和字體大小 [_userTextField setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"]; [_userTextField setValue:[UIFont boldSystemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"]; //_passwordTxetField的左視圖 UIImageView *passwdImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"locked"]]; //passwdImageView.frame = CGRectMake(0, 0, 37, 37); _passwordTxetField.contentMode = UIViewContentModeScaleAspectFit; _passwordTxetField.leftView = passwdImageView; _passwordTxetField.leftViewMode = UITextFieldViewModeAlways; _passwordTxetField.borderStyle = UITextBorderStyleRoundedRect; //修改水印字體色彩和字體大小 [_passwordTxetField setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"]; [_passwordTxetField setValue:[UIFont boldSystemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];

5. 自定義NavgationBar的標題和返回按鈕無文字的樣式和設置NavgationBar的背景圖

//自定義NavgationBar的標題 - (void)creatdTitle{ UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 45)]; label.text = @"標題"; label.font = [UIFont boldSystemFontOfSize:20]; label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor whiteColor]; self.navigationItem.titleView = label; } //返回按鈕無文字的樣式 - (void)createdbackBarButtonItem{ UIBarButtonItem *newBarButtonItem = [[UIBarButtonItem alloc] init]; newBarButtonItem.title = @""; self.navigationItem.backBarButtonItem = newBarButtonItem; [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]]; } //設置NavgationBar的背景圖 (jpg記得加后綴) [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"1"] forBarMetrics:UIBarMetricsDefault];

6. 自定義UIAlertController的標題、內容、和按鈕的字體樣式

- (void)created{ NSString *str = @"注 銷"; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert]; NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:str]; [alertControllerStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, str.length)]; [alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:25] range:NSMakeRange(0, str.length)]; [alertController setValue:alertControllerStr forKey:@"attributedMessage"]; UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"肯定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [cancelAction setValue:[UIColor grayColor] forKey:@"titleTextColor"]; [alertController addAction:confirmAction]; [alertController addAction:cancelAction]; [self presentViewController:alertController animated:YES completion:nil]; }

7. 驗證碼倒計時60S(注意UIButton樣式不能用系統的會閃)

//self.verificationBtn:改成你自己的命名的button - (void)startTime{ __block int timeout = 59; //倒計時時間 dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue); dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒履行 dispatch_source_set_event_handler(_timer, ^{ if(timeout<=0){ //倒計時結束,關閉 dispatch_source_cancel(_timer); dispatch_async(dispatch_get_main_queue(), ^{ //設置界面的按鈕顯示 根據自己需求設置(倒計時結束后調用) [self.verificationBtn setTitle:@"獲得驗證碼" forState:UIControlStateNormal]; [self.verificationBtn setBackgroundColor:[UIColor colorWithRed: 0/256.0 green: 111/256.0 blue: 255/256.0 alpha:1]]; //設置可點擊 self.verificationBtn.userInteractionEnabled = YES; }); }else{ // int minutes = timeout / 60; //這里注釋掉了,這個是用來測試多于60秒時計算分鐘的。 int seconds = timeout % 60; NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds]; dispatch_async(dispatch_get_main_queue(), ^{ //設置界面的按鈕顯示 根據自己需求設置 //NSLog(@"____%@",strTime); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1]; [self.verificationBtn setTitle:[NSString stringWithFormat:@"%@秒重新發送",strTime] forState:UIControlStateNormal]; [UIView commitAnimations]; self.verificationBtn.backgroundColor = [UIColor lightGrayColor]; //設置不可點擊 self.verificationBtn.userInteractionEnabled = NO; }); timeout--; } }); dispatch_resume(_timer); }

8. 各種切圓角(基本上能切得都這樣切)

//頭像圖片切圓 _userImageView.layer.cornerRadius = _userImageView.frame.size.width / 2; _userImageView.layer.masksToBounds = YES; // _textFiled.layer.cornerRadius = 10; _textFiled.layer.masksToBounds = YES; // view.layer.cornerRadius = 20; view.layer.masksToBounds = YES;

9.避免程序由于NSNull而致使奔潰

//創建個種別 #import <Foundation/Foundation.h> @interface NSNull (IsNull) @end #import "NSNull+IsNull.h" @implementation NSNull (IsNull) - (void)forwardInvocation:(NSInvocation *)invocation { if ([self respondsToSelector:[invocation selector]]) { [invocation invokeWithTarget:self]; } } - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector { NSMethodSignature *sig = [[NSNull class] instanceMethodSignatureForSelector:selector]; if(sig == nil) { sig = [NSMethodSignature signatureWithObjCTypes:"@^v^c"]; } return sig; } @end

10.AFNetworking的1個小問題(獲得數據的類型不對時,進行更改)

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/plain",@"text/html",@"image/jpg",nil];

11.極光推送程序內的代碼

//1.創建1個類 #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> @interface CFPushHelper : NSObject ///---------------------------------------------------- /// @name Setup 啟動相干 ///---------------------------------------------------- + (NSString *)registrationID; /*! * @abstract 啟動SDK * * @param launchingOption 啟動參數. * @param appKey 1個JPush 利用必須的,唯1的標識. 請參考 JPush 相干說明文檔來獲得這個標識. * @param channel 發布渠道. 可選. * @param isProduction 是不是生產環境. 如果為開發狀態,設置為 NO; 如果為生產狀態,應改成 YES. * @param advertisingIdentifier 廣告標識符(IDFA) 如果不需要使用IDFA,傳nil. * * @discussion 提供SDK啟動必須的參數, 來啟動 SDK. * 此接口必須在 App 啟動時調用, 否則 JPush SDK 將沒法正常工作. */ + (void)setupWithOption:(NSDictionary *)launchingOption appKey:(NSString *)appKey channel:(NSString *)channel apsForProduction:(BOOL)isProduction advertisingIdentifier:(NSString *)advertisingId; ///---------------------------------------------------- /// @name APNs about 通知相干 ///---------------------------------------------------- /*! * @abstract 注冊要處理的遠程通知類型 * * @param types 通知類型 * @param categories * * @discussion */ //+ (void)registerForRemoteNotificationTypes:(NSUInteger)types // categories:(NSSet *)categories; //上傳deviceToken + (void)registerDeviceToken:(NSData *)deviceToken; /*! * @abstract 處理收到的 APNs 消息 */ //+ (void)handleRemoteNotification:(NSDictionary *)userInfo; // ios7以后,才有completion,否則傳nil + (void)handleRemoteNotification:(NSDictionary *)userInfo completion:(void (^)(UIBackgroundFetchResult))completion; /*! * @abstract 前臺展現本地推送 * * @param notification 本地推送對象 * @param notificationKey 需要前臺顯示的本地推送通知的標示符 * * @discussion 默許App在前臺運行時不會進行彈窗,在程序接收通知調用此接口可實現指定的推送彈窗。 */ + (void)showLocalNotificationAtFront:(UILocalNotification *)notification identifierKey:(NSString *)notificationKey; @end //導入極光推送頭文件@"JPUSHService.h" #import "CFPushHelper.h" #import "JPUSHService.h" @implementation CFPushHelper + (NSString *)registrationID{ return [JPUSHService registrationID]; } + (void)setupWithOption:(NSDictionary *)launchingOption appKey:(NSString *)appKey channel:(NSString *)channel apsForProduction:(BOOL)isProduction advertisingIdentifier:(NSString *)advertisingId{ //Required if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { //可以添加自定義categories [JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]; } else { //categories 必須為nil [JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil]; } //Required // 如需繼續使用pushConfig.plist文件聲明appKey等配置內容,請照舊使用[JPUSHService setupWithOption:launchOptions]方式初始化。 [JPUSHService setupWithOption:launchingOption appKey:appKey channel:channel apsForProduction:isProduction advertisingIdentifier:advertisingId]; return; } + (void)registerDeviceToken:(NSData *)deviceToken{ [JPUSHService registerDeviceToken:deviceToken]; return; } //+ (void)handleRemoteNotification:(NSDictionary *)userInfo{ // // [CFPushHelper handleRemoteNotification:userInfo]; // //} + (void)handleRemoteNotification:(NSDictionary *)userInfo completion:(void (^)(UIBackgroundFetchResult))completion{ [JPUSHService handleRemoteNotification:userInfo]; if (completion) { completion(UIBackgroundFetchResultNewData); } return; } + (void)showLocalNotificationAtFront:(UILocalNotification *)notification identifierKey:(NSString *)notificationKey{ [CFPushHelper showLocalNotificationAtFront:notification identifierKey:nil]; return; } @end //我這里創建的AppDelegate的種別 #import "AppDelegate.h" @interface AppDelegate (CFPushSDK) - (void)JPushapplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; @end #import "AppDelegate+CFPushSDK.h" #import "JPUSHService.h" #import "CFPushHelper.h" #define JPushSDK_AppKey @"顧名思義" #define isProduction NO @implementation AppDelegate (CFPushSDK) - (void)JPushapplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [CFPushHelper setupWithOption:launchOptions appKey:JPushSDK_AppKey channel:nil apsForProduction:isProduction advertisingIdentifier:nil]; //注冊 NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(networkDidReceiveMessage:) name:kJPFNetworkDidLoginNotification object:nil]; } //通知方法 - (void)networkDidReceiveMessage:(NSNotification *)notification { //調用接口 NSLog(@"\n\n極光推送注冊成功\n\n"); //通知后臺registrationID //NSLog(@"registrationID2 = %@",[CFPushHelper registrationID]); NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (![CFPushHelper registrationID]) { NSString *registrationID = @"123"; [defaults setObject:registrationID forKey:@"registrationID"]; } else { [defaults setObject:[CFPushHelper registrationID] forKey:@"registrationID"]; } [defaults synchronize]; //[CFPushHelper registrationID] //注銷通知 [[NSNotificationCenter defaultCenter] removeObserver:self name:kJPFNetworkDidLoginNotification object:nil]; } - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { /// Required - 注冊 DeviceToken //NSLog(@"%@", [NSString stringWithFormat:@"Device Token: %@", deviceToken]); [CFPushHelper registerDeviceToken:deviceToken]; } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { // IOS 7 Support Required [CFPushHelper handleRemoteNotification:userInfo completion:completionHandler]; // 利用正處理前臺狀態下,不會收到推送消息,因此在此處需要額外處理1下 if (application.applicationState == UIApplicationStateActive) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"收到推送消息" message:userInfo[@"aps"][@"alert"] delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"肯定",nil]; [alert show]; } //[self gotoViewControllerWith:userInfo]; [self gotoViewController]; } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{ //NSLog(@"did Fail To Register For Remote Notifications With Error : %@",error); return; } - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{ [CFPushHelper showLocalNotificationAtFront:notification identifierKey:nil]; return; } - (void)applicationDidBecomeActive:(UIApplication *)application{ [application setApplicationIconBadgeNumber:0]; [application cancelAllLocalNotifications]; return; } @end #import "AppDelegate.h" #import "JPUSHService.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. //注冊極光推送 [self JPushapplication:application didFinishLaunchingWithOptions:launchOptions]; return YES; }

暫時就這樣

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 麻豆少妇 | 999精品在线播放 | 日韩中文字幕电影 | 免费在线国产视频 | 亚洲丁香社区久久丝袜综合网 | 中国成人在线视频 | 99精品国产在热久久婷婷 | 欧美九九 | 国产精品久久久久久久妇 | 中文字幕欧美一区 | 九九免费视频 | 色婷婷99se在线观看 | 国产黄在线看 | 亚洲a v网站 | 亚洲在线电影 | 欧美日韩视频在线 | 欧美国产在线视频 | 免费国产一区 | а天堂中文最新一区二区三区 | 国产午夜精品在线观看 | 黄a大片 | 色噜噜在线观看 | 精品久久久久久久久久久久 | 久久一本到 | 日本一区二区免费在线 | 嫩草影院一二三 | 久久综合成人精品亚洲另类欧美 | www.日| 在线观看国产 | 毛片久久 | 国产成人毛片 | 夜色亚洲 | 国产视频二区三区 | 三级成人av | 国产精品久久久久久久妇 | 日韩一级片一区二区 | 午夜精品一区二区三区在线播放 | 日韩视频欧美视频 | 久久精品视频在线 | 亚洲欧美久久 | 欧美日韩国产大片 |