2015-12-29html
【385】【scrollView不接受點擊事件,是由於事件傳遞失敗】ios
//git
// MyScrollView.mgithub
// Created by beyond on 15/6/6.web
// Copyright (c) 2015年 beyond.com All rights reserved.正則表達式
// 不必定要用繼承,可使用分類json
#import "MyScrollView.h"c#
#import "CoView.h"api
@implementation MyScrollView數組
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
if(!self.dragging)
{
UITouch *touch = [touches anyObject];
CGPoint loc = [touch locationInView:self];
// x y轉成coView中的座標
CGFloat x = loc.x - 10;
CoView *coView = (CoView *)[self viewWithTag:5267];
CGFloat y = loc.y - coView.y;
CGPoint newLoc = [coView convertPoint:loc fromView:self];
// 通過驗證:x == newLoc.x y == newLoc.y
x = newLoc.x;
y = newLoc.y;
// 如今就是經過point 算出 row,col,進而的推算出i
int col = x/(kBtnWH+kBtnMarginH);
int row = y/(kBtnWH+kBtnMarginV);
int i = row*kBtnColumnNum + col;
[[self nextResponder] touchesBegan:touches withEvent:event];
// 注意,coView處理的時候,i越界的狀況要處理;i從0開始
DLog(@"--點了第%d個---",i);
[coView btnTouched:i];
}
[super touchesBegan:touches withEvent:event];
//NSLog(@"MyScrollView touch Began");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(!self.dragging)
{
[[self nextResponder] touchesEnded:touches withEvent:event];
}
[super touchesEnded:touches withEvent:event];
}
@end
【382】【帶暫停和繼續的NSTimer】
#import
@interface NSTimer (Pause)
@property (nonatomic, strong, readwrite) NSString *state;
-(void)pause;
-(void)resume;
@end
///////////////////////////////////////////////////////////////////////////
#import "NSTimer+Pause.h"
#import
static void *state = (void *)@"state";
@implementation NSTimer (Pause)
-(void)pause
{
if (![self isValid]) {
return ;
}
[self setFireDate:[NSDate distantFuture]]; //若是給我一個期限,我但願是4001-01-01 00:00:00 +0000
}
-(void)resume
{
if (![self isValid]) {
return ;
}
[self setFireDate:[NSDate date]];
}
- (NSString *)state
{
return objc_getAssociatedObject(self, state);
}
- (void)setState:(NSString *)s
{
objc_setAssociatedObject(self, state, s, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
【381】【給分類添加屬性】
// Declaration
@interface MyObject (ExtendedProperties)
@property (nonatomic, strong, readwrite) id myCustomProperty;
@end Implementation
static void * MyObjectMyCustomPorpertyKey = (void *)@"MyObjectMyCustomPorpertyKey";
@implementation MyObject (ExtendedProperties)
- (id)myCustomProperty
{
return objc_getAssociatedObject(self, MyObjectMyCustomPorpertyKey);
}
- (void)setMyCustomProperty:(id)myCustomProperty
{
objc_setAssociatedObject(self, MyObjectMyCustomPorpertyKey, myCustomProperty, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
【367】【評論提示後返回】
[SVProgressHUD showSuccessWithStatus:@"提交成功"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[blockSelf.navigationController popViewControllerAnimated:YES];
});
【365】【每一組的最新記錄:分組以前 先排序】
select max(FTime),* FROM DynamicInfoTable WHERE FUID = 'd441e1d7-2362-4c7e-9486-37fd834b3232' group by FOrgID,FType order by max(FTime) DESC
【363】【label文字左邊距】
UIView *leftview = [[UIView alloc] initWithFrame:frame];
textField.leftViewMode = UITextFieldViewModeAlways;
textField.leftView = leftview; //imageView
【362】【返回以前,必須退出鍵盤】【#pragma mark - 返回提示 // 返回,因爲是發佈頁面,因此要檢查 提示 防止誤操做 - (void)back:(id)sender { BOOL hasSomething = [self formHasSomething]; if (hasSomething) { // 提示 // 發送請求,刪除 UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"舒適提示" message:@"您肯定要放棄發佈並返回嗎?" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"肯定", nil]; alertView.confirmBlock = ^(){ // 調用父類的返回 [super back:sender]; }; [alertView show]; return; }else{ [self.view endEditing:YES]; [super back:sender]; } }】
【358】【3G4G自動下載圖片】
#import "UIImageView+Download.h"
// 異步下載圖片
#import "UIImageView+WebCache.h"
#import "KLNetworkStatus.h"
#import "KLTools.h"
@implementation UIImageView (Download)
- (void)downloadImgWithUrlString:(NSString *)urlString placeHolderImgName:(NSString *)placeHolderImgName
{
if (!(urlString.length > 0)) {
//沒有圖片,直接使用默認圖
self.image = [UIImage imageNamed:placeHolderImgName];
return;
}
NSURL *url = [NSURL URLWithString:urlString];
// 1.先從緩存中取,若是緩存中有:直接設置
SDWebImageManager *manager = [SDWebImageManager sharedManager];
BOOL isImgAlreadyExists = [manager cachedImageExistsForURL:url];
if (isImgAlreadyExists) {
UIImage *image = [manager.imageCache imageFromDiskCacheForKey:urlString];
[self setImage:image];
return;
}
// 2.若是緩存中沒有,若是是WIFI,下載
BOOL isWifi = [[KLNetworkStatus sharedKLNetworkStatus] isReachableViaWifi];
if (isWifi) {
[self sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:placeHolderImgName]];
return;
}
// 3.若是是3G/4G,則要再進行判斷用戶是否開啓了 自動下載
BOOL isWWAN = [[KLNetworkStatus sharedKLNetworkStatus] isReachableViaWWAN];
if (isWWAN) {
BOOL isAllowDownload = [KLTools isNetworkDownloadSet];
if (isAllowDownload) {
[self sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:placeHolderImgName]];
return;
}
}
}
@end
【348】【判斷是否安裝weixin】
[WXApi isWXAppInstalled]方法無效
使用下面這個
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"weixin://"]])
{
NSLog(@"OK weixin://");
}
【347】【導航標題】【self.navigationItem.title = @"發佈";】
【346】【xib中的cell無端多出一個半透明灰灰的40高、300寬的label,經過po打印,發現是兩個label,猜想是contentLabel和detailLabel】
產生緣由:是因爲在xib選擇了一次cell的accessory爲detail,結果 在xib代碼中 添加了兩個label,
所以,即便 再次將accessory選擇爲no,那兩個label依然在xib代碼中。。。。
(lldb) po self
>
(lldb) po self.contentView
; layer = >
(lldb) po [self.contentView subviews]
<__NSArrayM 0x6ffb850>(
>,
>,
>,
>,
>,
>,
>
)
【345】【正則,表情匹配{:001:}對應的是@"\\{:\\d\\d\\d:\\}",注意括號都要轉義】
@"\\{:\\d\\d\\d:\\}"反解析 表情文字
+(NSString *) FContentPrettyFaceText:(NSString *)faceText
{
NSString *str = faceText;
NSString *pattern = @"\\{:\\d\\d\\d:\\}";
NSError *error = NULL;
//定義正則表達式
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
//使用正則表達式匹配字符
NSArray *arr = [regex matchesInString:str options:0 range:NSMakeRange(0, [str length])];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"facesDic.plist" ofType:nil]];
if (arr.count != 0)
{
for (long i = arr.count - 1; i >= 0; i--) {
NSTextCheckingResult *result = arr[i];
NSRange range = [result range];
// 開始位置好比:9
int loc = range.location;
// 長度固定是 7
int len = range.length;
// {:067:}
NSString *subStr = [str substringWithRange:range];
NSString *key = [subStr substringWithRange:NSMakeRange(2, 3)];
// key:067
NSString *value = [dict objectForKey:key];
// [愛心]
// 首
NSString *head = [str substringToIndex:loc];
// 尾
NSString *tail = [str substringFromIndex:loc + len];
str = [NSString stringWithFormat:@"%@%@%@",head,value,tail];
}
}
return str;
}
【343】【奇怪的bug】
問題描述:
1、tableView是經過IB,而且有自動佈局;
2、headView是經過代碼建立的
3、給tableView加headView,沒有問題
4、給tableView加footerView,當用代碼建立時,也沒有問題
5、可是:當footerView是用自動佈局時,tableView首次展現時,footView高度爲0;
可是,當jump到一個控制器,而且再次返回時,tableView再次顯示,此時footView高度正常了。。。
問題緣由:
猜想是:tableView的自動佈局影響的
解決方法:
當前 想到的是:線程延遲幾秒再給tableView設置footView
self.tableView.tableHeaderView = self.headView;
_footerView = [RowView RowView];
// 這裏加個延遲,否則會高度爲0,應該是自動佈局致使的問題
kWeakSelf
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
kStrongSelf
strongSelf.tableView.tableFooterView = _footerView;
[UIView animateWithDuration:5 animations:^{
[strongSelf.view layoutIfNeeded];
[strongSelf.tableView layoutIfNeeded];
}];
});
【342】【只要約束改變後,就要手動刷新對應的view】
_topView.bigImgHeightConstraint.constant = 0;
[UIView animateWithDuration:0.3 animations:^{
[self.view layoutIfNeeded];
[_topView layoutIfNeeded];
}];
【340】【IB控件用weak,String用copy,delegate用weak,block用copy,對象類型用Strong,基本類型用assign】
@property (nonatomic,weak) IBOutlet UILabel *label;
- (IBAction)xxxBtnClicked:(UIButton *)sender;
【335】【label圖文混排CBEmotionView】【 使用core text 和 core graphics 實現的文字與表情圖片的並排繪製】
【334】【Localizable.strings】
//
// Localizable.strings
本地資源文件
//
// Created by beyond on 15/3/19.
// Copyright (c) 2015年 beyond. All rights reserved.
//
"appName"="XXX";
"login_now"="當即登陸";
"vip_showmsg"="請聯繫您孩子的班主任開通VIP服務";
NSString *str = NSLocalizedString(@"vip_showmsg", nil);
UIActionSheet *sheet = [[UIActionSheet alloc]initWithTitle:str delegate:self cancelButtonTitle:@"關閉" destructiveButtonTitle:@"購買VIP" otherButtonTitles:@"聯繫客服", nil];
[sheet showInView:self.view];
【333】【禁用單個頁面手勢滑動返回功能】
在有的時候,咱們不須要手勢返回功能,那麼能夠在頁面中添加如下代碼:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// 禁用 iOS7 返回手勢
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// 開啓
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
#define KLNavigationBarHidden [self.navigationController setNavigationBarHidden:YES animated:YES];
#define KLNavigationBarShow [self.navigationController setNavigationBarHidden:NO animated:YES];
【332】【反斜槓】
在嗎 NSString 如何表示反斜槓呀 \
NSString *path = @"main\";
打一個錯誤, \和「挨一塊兒就出錯,打兩個 NSString *path = @"main\\";能夠,可是後面
[path appendString @"d盤"];之後,
實際的path內容爲"main\\d盤" 怎麼弄一個單反斜槓呀??
NSString *str = [NSString stringWithFormat:@"%@\\%@",@"main",@"d盤"];
NSLog(@"str:%@",str);
我發現了,這是個顯示的問題,在Debuger Console裏能夠正常顯示,在調試中卻顯示成兩個斜槓,轉意字符應該是好使的,即NSString中,""\\"",就是 一個"\" 的轉意字符,和c的和c++的同樣,只是調試時顯示的值有bug罷了。
【331】【data-->string-->OC對象】
(lldb) po data
<7b225374 61747573 436f6465 223a3530 302c2245 72726f72 4d657373 61676522 3a22e794 a8e688b7 e4b88de5 ad98e59c a8e68896 e5af86e7 a081e994 99e8afaf efbc8122 2c22436f 6e74656e 74223a6e 756c6c7d>
(lldb) po responseString
{"StatusCode":500,"ErrorMessage":"用戶不存在或密碼錯誤!","Content":null}
2015-05-21 14:26:31.952 JZH[161:60b] __70-[NetRequest initWithAction:userId:password:otherParam:completeBlock:]_block_invoke [Line 209] responseObject ==== {
Content = "";
ErrorMessage = "\U7528\U6237\U4e0d\U5b58\U5728\U6216\U5bc6\U7801\U9519\U8bef\Uff01";
StatusCode = 500;
}
【330】【label中顯示錶情】【查看原文】
【327】【金額用NSNumber接收,必須strong引用 不然 內存釋放,崩掉】
//金額
@property (nonatomic,strong) NSNumber *orderPrice;
double currentPrice = [model.FCurrentPrice doubleValue];
_topView.currentLabel.text = [NSString stringWithFormat:@"¥%.02lf",currentPrice];
【326】【xcode6建分類】【左上角file菜單---》new File---->Objective-c File---->Category】
【325】【通知】
- (void)xxxNoti:(NSNotification *)noti
{
//獲取鍵盤的高度
NSDictionary *dict = [noti userInfo];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
// 監聽支付成功
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(paySuccess) name:@"notificationCenter_paySuccess" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"notificationCenter_paySuccess" object:nil];
【324】【webview死活不執行js代碼】
webview加載本地html須要時間,同時,經過id向服務器獲取詳情也須要時間,所以:極可能當服務器已經獲取到detail信息時,本地的html還沒有加載完畢,故出現上述狀況
【323】【UIAlertView+Block】
#import
typedef void (^UIAlertViewBlock)(UIAlertView *alertView, NSInteger buttonIndex);
typedef void (^ConfirmBlock)(void);
@interface UIAlertView(Block)
@property (nonatomic,copy)ConfirmBlock confirmBlock;
@property (nonatomic,copy)UIAlertViewBlock clickBlock;
// 必須手動用運行時綁定方法
- (void)setConfirmBlock:(ConfirmBlock)confirmBlock;
- (ConfirmBlock)confirmBlock;
- (void)setClickBlock:(UIAlertViewBlock)clickBlock;
- (UIAlertViewBlock)clickBlock;
@end====================
#import "UIAlertView+Block.h"
#import
@implementation UIAlertView(Block) 必須手動用運行時綁定方法
- (void)setConfirmBlock:(ConfirmBlock)confirmBlock
{
objc_setAssociatedObject(self, @selector(confirmBlock), confirmBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
if (confirmBlock == NULL) {
self.delegate = nil;
}
else {
self.delegate = self;
}
}
- (ConfirmBlock)confirmBlock
{
return objc_getAssociatedObject(self, @selector(confirmBlock));
}
必須手動用運行時綁定方法
- (void)setClickBlock:(UIAlertViewBlock)clickBlock
{
objc_setAssociatedObject(self, @selector(clickBlock), clickBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
if (clickBlock == NULL) {
self.delegate = nil;
}
else {
self.delegate = self;
}
}
- (UIAlertViewBlock)clickBlock
{
return objc_getAssociatedObject(self, @selector(clickBlock));
}
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
// 肯定
if (self.confirmBlock) {
// self.confirmBlock(self, buttonIndex);
self.confirmBlock();
}
} else {
// 取消或其餘
}
if (self.clickBlock) {
self.clickBlock(self, buttonIndex);
}
}
@end====================
// 發送請求,刪除
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"舒適提示" message:@"您肯定要放棄發佈並返回嗎?" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"肯定", nil];
alertView.confirmBlock = ^(){
// 調用父類的返回
[super doBack:sender];
};
[alertView show];
【322】【按鈕,左圖 右文字】
#import "OperationBtn.h"
#define kMargin 5
@implementation OperationBtn
- (void)setHighlighted:(BOOL)highlighted
{
// do nothing 就是取消默認的高亮狀態
}
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
// 圖片等寬高(15,整個按鈕是25,圖片左上邊距全是5)
CGFloat wh = contentRect.size.height - kMargin - kMargin ;
CGRect rect = CGRectMake(kMargin, kMargin, wh, wh);
return rect;
}
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
// 文字居右 (圖片15*15)
CGFloat wh = contentRect.size.height - kMargin - kMargin;
CGFloat x = kMargin + 15 + 3;
CGFloat y = kMargin + 3;
CGRect rect = CGRectMake(x, kMargin,contentRect.size.width - x, wh);
return rect;
}
- (void) setEnabled:(BOOL)enabled
{
DLog(@"setEnabled方法:%d",enabled );
[super setEnabled:enabled];
}
@end
【321】【No matching provisioning profiles found】
問題:Your build settings specify a provisioning profile with the UUID 「dedebf56-8f41-4af9-aeb8-5ec59fe02fedbeyond」, however, no such provisioning profile was found. Xcode can resolve this issue by downloading a new provisioning profile from the Member Center.
解決方法:
targets---build settings---- code signing----provisioning profile----debug
【320】【自動佈局按鈕排列】【先所有與父類對齊,而後設置一下乘積因子】【查看原文】
【315】【webview執行js函數注意事項】
url has prefix 判斷時,要注意ios統一加http://而且注意大小寫哦~~~
字符串參數要用單引號
數字不用
true用數字1
而且jsonString必須使用NSJSONReadingMutableLeaves,
不能使用pretty風格,以下所示:
NSData *data = [NSJSONSerialization dataWithJSONObject:bigDict options:NSJSONReadingMutableLeaves error:nil];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
【314】【奇怪的問題】【在cell的xib文件中 添加了一個控件如label,而且IBOutlet連線,可是:運行的時候該label卻沒有初始化顯示爲nil】
【312】【JSBadgeView 是一個可定製的在視圖上顯示徽章的 iOS 組件】
【311】【iphone6截屏750 X 1334】
【310】【框架請求失敗,提示405不支持POST,只allow GET】
位於類:AFHTTPRequestOperation.m
位於方法:
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
具體代碼:
id responseObject = self.responseObject;
if (self.error) {
if (failure) {
dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
failure(self, self.error);
});
}
} else {
if (success) {
dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
success(self, responseObject);
});
}
}
(lldb) po self.response
{ URL: http://192.168.1.124:555/api/System/GetUserIdentityInfo } { status code: 405, headers {
Allow = GET;
"Cache-Control" = "no-cache";
"Content-Length" = 73;
"Content-Type" = "application/json; charset=utf-8";
Date = "Mon, 11 May 2015 06:22:47 GMT";
Expires = "-1";
Pragma = "no-cache";
Server = "Microsoft-IIS/7.5";
"X-AspNet-Version" = "4.0.30319";
"X-Powered-By" = "ASP.NET";
} }
(lldb) po self.responseObject
{
Message = "The requested resource does not support http method 'POST'.";
}
【309】【關於xcode本身revoke(吊銷)certificate(證書)的問題】
緣由:新target運行項目的時候,提示找不到描述文件;xcode提議 自動fix issue
描述:這時候,xcode會 revoke(吊銷)原來的certificate(證書),所以,與原來證書相關聯的描述文件,所有會失效;
解決方法:正確的作法是:從團隊其餘人員拷貝描述文件到本機,雙擊導入;在xcode項目配置的設置中 選擇剛纔導入的描述文件,進而選擇code sign identity
【308】【方形圖片變圓】
70 * 70的話,圓角只要設置成half便可,即:35
// 從xib中加載 實例化一個SynClassCell對象
+ (ParentDetailTopView *)ParentDetailTopView
{
// mainBundel加載xib,擴展名不用寫.xib
NSArray *arrayXibObjects = [[NSBundle mainBundle] loadNibNamed:@"ParentDetailTopView" owner:nil options:nil];
ParentDetailTopView *topView = [arrayXibObjects firstObject];
topView.headImgView.layer.masksToBounds = YES;
topView.headImgView.layer.cornerRadius = 35.f;
return topView;
}
【305】【scrollView滾動範圍】【// 重置contentView的滾動範圍必須大於其bounds的高,才能滾動】
【304】【cell側滑ime刪除】
1.dataSource的方法:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
此方法就是給一個空的實現滑動也會出現刪除按鈕!!
2. 必須先刪除數據源
[blockSelf.arrayData removeObjectAtIndex:indexPath.row];
// 再刪除view
[blockSelf.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[blockSelf.tableView reloadData];
【301】【彈出動畫】
注意在viewDidAppear調用
- (void)addKeyAnimation
{
CAKeyframeAnimation * animation;
animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.duration = 0.5;
animation.delegate = self;
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeForwards;
NSMutableArray *values = [NSMutableArray array];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
animation.values = values;
[_contentView.layer addAnimation:animation forKey:nil];
}
【299】【ineligible devices】
iphone 6 with 8.3系統,鏈接到xcode 6.01 時,
提示:ineligible devices
緣由:xcode版本過低
解決辦法:
換成xcode 6.1 便可
==============
Xcode 6.1 update. The 6.0.1 does't support iOS 8.1.
【查看原文】
【298】【二次包裝過程】
將一個字典,包裝成一個大的大典,再轉成jsonString
// 二次包裝過程
NSArray *modelArr = [MarkModel objectArrayWithKeyValuesArray:dataArr];
MarkBigModel *bigModel = [[MarkBigModel alloc]init];
bigModel.FScore = 5;
NSArray *dictArray = [MarkModel keyValuesArrayWithObjectArray:modelArr];
bigModel.MciMcBusiSiteRemarkItems = dictArray;
bigModel.RemarkCount = modelArr.count;
// 模型 轉 字典,以後就能夠用字典 轉 jsonString
NSDictionary *bigDict = bigModel.keyValues;
另1種是 經過NSJSONSerialization 轉成Data,再從Data 轉成jSON string,會有反斜線
NSData *data = [NSJSONSerialization dataWithJSONObject:bigDict options:NSJSONReadingMutableLeaves error:nil];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
【297】【OC的字典轉成jsonString】
// 重要說明:content此時已經從json串 轉成了OC的字典 1種是 經過JSONKIT,可將字典轉成json字符串;
// self.jsonString = [(id)content JSONString]; 另1種是 經過NSJSONSerialization 轉成Data,再從Data 轉成jSON string
NSData *data = [NSJSONSerialization dataWithJSONObject:content options:NSJSONWritingPrettyPrinted error:nil];
self.jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
【296】【appdelegate中的支付回調1】
// pay ---- 3
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
[Pingpp handleOpenURL:url withCompletion:nil];
[[NSNotificationCenter defaultCenter]postNotificationName:@"notificationCenter_userPayOrNot" object:nil];
return YES;
(lldb) po url
jzh://pingpp?result=success
(lldb) po sourceApplication
com.apple.mobilesafari
(lldb) po annotation
nil
(lldb)
}
【293】【代碼改約束】
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// // 當事件觸發時,改變其constant值,而後調用約束所在的對象的 layoutIfNeeded方法,固定的~ 例如:
// _topView.collectionViewHeightConstraint.constant = 50;
// // self.leftMarginConstraint.constant = 100;
// // self.widthConstraint.constant = 200;
// [UIView animateWithDuration:2.0 animations:^{
// [self.view layoutIfNeeded];
// [_topView layoutIfNeeded];
// }];
});
【292】【cell圖片在xib中aspect fit無效,只能用代碼調整】
self.img.contentMode = UIViewContentModeScaleAspectFill;
self.img.clipsToBounds = YES;
【291】【cell分割線設置,實際上是tableView的屬性separatorStyle】
將UITableView的separatorStyle屬性設置爲UITableViewCellSeparatorStyleNone便可,以下:
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
【289】【隱藏導航條】
// 導航控制器的顯示和隱藏【提示,若是使用navigationBarHidden屬性,側滑會出問題】
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.navigationController.navigationBar.hidden = NO;
}
【286】【Cell點擊特效 取消】
cell.selectionStyle = UITableViewCellSelectionStyleNone;
【285】【動畫特效1】
CAKeyframeAnimation * animation;
animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.duration = 0.5;
animation.delegate = self;
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeForwards;
NSMutableArray *values = [NSMutableArray array];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
animation.values = values;
[_contentView.layer addAnimation:animation forKey:nil];
【284】【url schemes】
工程--->targets--->info--->urlTypes
identifier: com.sg31.www
url schemes: beyond
下面的爲接收到外部調用的時候程序啓動,響應方法,在safari輸入:beyond://com.sg31.www
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
if ([[url scheme] isEqualToString:@"beyond"]) {
NSLog(@"外部調用成功");
}
return YES;
}
【283】【iOS開發的一些奇巧淫技】【進入網址】
【282】【auto adjust cell】
viewdidload
tableView.rowHeight = UITableViewAutomaticDimension;
tableView.estimatedRowHeight = 10;
cellForRow
[cell layoutIfNeeded];
【281】【btn獲得cell獲得table獲得row】
while (![btn isMemberOfClass:[self class]]){
btn = (UIButton *)[btn superview];
}
MyProjectCell *cell = (MyProjectCell *)btn;
UITableView *tableView = (UITableView *)cell;
while (![tableView isMemberOfClass:[UITableView class]]){
tableView = (UITableView *)[tableView superview];
}
NSIndexPath *path = [tableView indexPathForCell:cell];
row = path.row;
// 已經棄用,調用外界的控制器的block,並將cell的行號傳遞過去
// _wannaChangeStatusBlock(row); 調用外界的控制器的block,並將cell的行號傳遞過去
_wannaChangeStatusBlockExt(row,cell);
【279】【textView佔位】
Easy way, just create placeholder text in UITextView by using the following UITextViewDelegate methods:
- (void)textViewDidBeginEditing:(UITextView *)textView
{
if ([textView.text isEqualToString:@"placeholder text here..."]) {
textView.text = @"";
textView.textColor = [UIColor blackColor]; //optional
}
[textView becomeFirstResponder];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
if ([textView.text isEqualToString:@""]) {
textView.text = @"placeholder text here...";
textView.textColor = [UIColor lightGrayColor]; //optional
}
[textView resignFirstResponder];
}
just remember to set myUITextView with the exact text on creation e.g.
UITextView *myUITextView = [[UITextView alloc] init];
myUITextView.delegate = self;
myUITextView.text = @"placeholder text here...";
myUITextView.textColor = [UIColor lightGrayColor]; //optional
and make the parent class a UITextViewDelegate before including these methods e.g.
@interface MyClass ()
@end
【進入網址】
【274】【nsrange,是 一個結構體,方法: NSMakeRange(<#NSUInteger loc#>, <#NSUInteger len#>)】
【273】【iOS開發的一些奇巧淫技】【查看原文】
【272】【awakeFromNib】
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)awakeFromNib{
[super awakeFromNib];
NSLog(@"call %s", __FUNCTION__);
self.backgroundColor = [UIColor redColor];
// 其餘初始化方法
}
【271】【先對數組統一排序,再進行分組,再組內排序】
// 其餘狀況,返回是數組
NSMutableArray *contentDictArr = (NSMutableArray *)content;
DLog(@"返回是數組,長度是 %d",contentDictArr.count);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// NSArray 轉成 NSMutableArray
// 0、對於不啓用的,即enabled爲0的字典模型,刪除掉
NSMutableArray *dictArr = [NSMutableArray array];
for (NSInteger i = 0; i < contentDictArr.count; i++) {
NSDictionary *dict = contentDictArr[i];
if ([[dict objectForKey:@"FEnabled"]intValue] == 1) {
[dictArr addObject:dict];
}
}
// DLog(@"清除未啓用的字典後的數組:%@",dictArr);
// 0.1、對於被包含的模塊,暫時剔除
NSMutableArray *tempdictArr = [NSMutableArray array];
for (NSInteger i = 0; i < dictArr.count; i++) {
NSDictionary *dict = dictArr[i];
// 若是有值,則說明是某個模塊的子模塊@"26e86235-e04c-46e1-a7d5-6d513c02de39"
// 若是沒有值,即NSNull,表示是根目錄模塊,直接展現
if ([[dict objectForKey:@"FUpCMID"] class] == [NSNull class]) {
[tempdictArr addObject:dict];
}
} 1、對數組按GroupTag排序
NSArray *sortDesc = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"FGroupTag" ascending:YES]];
NSArray *sortedArr = [tempdictArr sortedArrayUsingDescriptors:sortDesc];
// DLog(@"排序後的數組:%@",sortedArr);
2、對數組進行分組,按GroupTag
// 遍歷,建立組數組,組數組中的每個元素是一個模型數組
NSMutableArray *testGroupArr = [NSMutableArray array];
NSMutableArray *currentArr = [NSMutableArray array];
// 由於確定有一個字典返回,先添加一個
[currentArr addObject:sortedArr[0]];
[testGroupArr addObject:currentArr];
// 若是不止一個,纔要動畫添加
if(sortedArr.count > 1){
for (NSInteger i = 1; i < sortedArr.count; i++) {
// 先取出組數組中 上一個模型數組的第一個字典模型的groupID
NSMutableArray *preModelArr = [testGroupArr objectAtIndex:testGroupArr.count-1];
NSInteger preGroupID = [[[preModelArr objectAtIndex:0] objectForKey:@"FGroupTag"] intValue];
// 取出當前字典,根據groupID比較,若是相同則添加到同一個模型數組;若是不相同,說明不是同一個組的
NSDictionary *currentDict = sortedArr[i];
NSInteger groupID = [[currentDict objectForKey:@"FGroupTag"] intValue];
if (groupID == preGroupID) {
[currentArr addObject:currentDict];
}else{
// 若是不相同,說明 有新的一組,那麼建立一個模型數組,並添加到組數組testGroupArr
currentArr = [NSMutableArray array];
[currentArr addObject:currentDict];
[testGroupArr addObject:currentArr];
}
}
}
// 3、遍歷 對每一組 進行排序
NSMutableArray *tempGroupArr = [NSMutableArray array];
for (NSArray *arr in testGroupArr) {
// NSArray *sortDesc = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"FOrder" ascending:YES]];
NSArray *tempArr = [arr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
if([[obj1 objectForKey:@"FOrder"]intValue] < [[obj2 objectForKey:@"FOrder"]intValue]){
return NSOrderedAscending;
}
if([[obj1 objectForKey:@"FOrder"]intValue] > [[obj2 objectForKey:@"FOrder"]intValue]){
return NSOrderedDescending;
}
return NSOrderedSame;
}];
[tempGroupArr addObject:tempArr];
}
testGroupArr = tempGroupArr;
DLog(@"封裝好的group數組:%@",testGroupArr);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// testGroupArr 將封裝好的字典數組緩存起來,以便下次調用 userDefault_localGroupArr
// 根據用戶上次選擇的,展現
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
[userDefault setBool:YES forKey:@"userDefault_hasCached_moduleDictArr"];
NSString *jsonStr = testGroupArr.JSONString;
DLog(@"沒有網絡的時候用:jsonStr:%@",jsonStr);
[userDefault setObject:jsonStr forKey:@"testGroupArr_jsonStr"];
[userDefault sync
【270】【自動佈局scrollView】
contentSize 必須明確指定,如label距離下方多少,距離右邊多少,這樣才能夠 讓scrollView計算出contentSize
【查看原文】
【267】【inDatabase: was called reentrantly on the same queue, which would lead to a deadlock】
在使用時,若是在queue裏面的block執行過程當中,又調用了 indatabase方法,則會檢查 是否是同一個queue,若是是同一個queue會死鎖;緣由很簡單:
隊列裏面 放了一個block,該block又在 本隊列 後面放了一個 block;
從而:前一個block 裏面 調用了 後一個block,必須等後一個block執行完成了,
前一個block纔會 出隊列;
然後一個block想要執行,則又必須先等 前一個block出隊列;
所以 死鎖!!!!
解決方法:在indatabase的block中,不要再調用indatabase方法
[[[DBHelper shareInstance] dbQueue]inDatabase:^(FMDatabase *db){
isSuccess = [self.helper update4Table:TB_User_Friend withArgs:args where:where];
}];
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- (void)inDatabase:(void (^)(FMDatabase *db))block {
/* Get the currently executing queue (which should probably be nil, but in theory could be another DB queue
* and then check it against self to make sure we're not about to deadlock. */
FMDatabaseQueue *currentSyncQueue = (__bridge id)dispatch_get_specific(kDispatchQueueSpecificKey);
assert(currentSyncQueue != self && "inDatabase: was called reentrantly on the same queue, which would lead to a deadlock");
}
【261】【ios_xib_preview預覽】
右上方----show the assistant edit ---- 選擇新窗口中manual最下方的Preview
【258】【應該豎屏,僅在視頻播放頁面橫屏】
在app delegate中,啓動時,
[userDefault setBool:NO forKey:@"userDefault_isAllowLandscape"];
[userDefault synchronize];
在app delegate中,經過一個本地保存的key進行判斷,是否進行橫屏
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
// 全局的設置:容許豎屏+橫屏
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
BOOL isAllowLandscape = [userDefault boolForKey:@"userDefault_isAllowLandscape"];
if (isAllowLandscape) {
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscape;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
在視頻播放控制器中,更改本地保存的key便可
【257】【模擬器上面 播放視頻崩潰】
iphone 4s 8.0系統的模擬器上面 播放視頻:
崩潰:
Apr 9 11:44:39 [jun] rtcreporting[57158] : logging starts...
Apr 9 11:44:39 [jun] rtcreporting[57158] : setMessageLoggingBlock: called
緣由:
在模擬器上面播放視頻
解決辦法:
去掉全局斷點,這是一個bug
【256】【iphone真機死活不旋轉】
死活不走代理方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
緣由多是:手機上拉快速設置欄中:豎排方向鎖定 :打開了
【255】【導航返回按鈕】
UIButton* btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width+10, 40)];
btn.showsTouchWhenHighlighted = YES;
[btn setImage:image forState:UIControlStateNormal];
[btn addTarget:theTarget action:sel forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] initWithCustomView:btn];
backBtn.tag = 9528;
vc.navigationItem.leftBarButtonItem = backBtn;
【254】【ios_VLC】
VLC for iOS 2.3.0
關於VLC配置問題,根據我的經驗整理了一下,但願能幫到須要的朋友。
官網連接:https://wiki.videolan.org/IOSCompile/
百度雲盤連接:http://pan.baidu.com/s/1bnEOXPH 密碼:ur4l
配置說明(百度雲盤)
官網按照說明操做就能夠了只是下載的地址是個谷歌的什麼網站,因此你懂得。
百度雲盤下載下來後須要配置下文件VLC/ios/External 這個文件夾下面有六個文件(快捷方式):MediaLibraryKit,MobileVLCKit,PLCrashReporter,QuincyKit,gtl,upnpx
從新配置下這六個文件路徑就能夠用了,vlc源碼是區分真機和模擬器的
終端配置路徑
1、在終端進入External文件夾
2、ln -s -f是終端修改文件路徑的,關於終端命令不懂的朋友請百度,在此就不班門弄斧了。
真機就用Release-iphoneos,模擬器就用Release-iphonesimulator
ln -s -f /Users/stlink/Desktop/VLC/ios/ImportedSources/MediaLibraryKit/build/Release-iphoneos MediaLibraryKit
ln -s -f /Users/stlink/Desktop/VLC/ios/ImportedSources/VLCKit/build/Release-iphoneos MobileVLCKit
ln -s -f /Users/stlink/Desktop/VLC/ios/ImportedSources/PLCrashReporter/build/Release-iphoneos PLCrashReporter
ln -s -f /Users/stlink/Desktop/VLC/ios/ImportedSources/QuincyKit/client/iOS/QuincyLib/build/Release-iphoneos QuincyKit
ln -s -f /Users/stlink/Desktop/VLC/ios/ImportedSources/GDrive/build/Release-iphoneos gtl
ln -s -f /Users/stlink/Desktop/VLC/ios/ImportedSources/upnpx/projects/xcode4/upnpx/build/Release-iphoneos upnpx
3、路徑正確的話就沒問題了,ls -l 查看文件路徑
修改完成後就能夠啓動了VLC/iOS/VLC for iOS.xcodeproj
注意:我有時候配置正確路徑可是文件仍是報錯,這種狀況的話解壓從新搞吧,暫時不知道怎麼處理。
SimplePlayback
這個是VLC在線播放的一個demo,路徑:VLC/ios/ImportedSources/VLCKit/Examples_iOS/SimplePlayback
項目直接拷貝出來不能用的,要配置下。
libMobileVLCKit.a 這個demo用到這個靜態庫。靜態庫區分真機和模擬器的。靜態庫我不太懂怎麼配置,搞了幾回沒搞定
不過有另外的辦法MobileVLCKit.framework這個不區分真機和模擬器的。
路徑:VLC/ios/ImportedSources/VLCKit/build
注意:Deployment target 要低於7.0
END
最後但願能幫到須要的朋友,不懂得能夠聯繫我,qq:527993842,加好友請說明謝謝,因爲工做緣由可能沒法及時回覆請見諒,並且我也是剛接觸vlc。
關鍵詞:iOS VLC
MediaLibraryKit項目中的Search paths使用相對路徑就能夠了。
Header Search Paths --> ../../External/MobileVLCKit/include
Library Search Paths --> ../../External/MobileVLCKit
MediaLibraryKit項目中相對路徑$(SRCROOT)獲得的值是/XXX/XXX/VLC/ios/ImportedSources/MediaLibraryKit,而不是想象中的/XXX/XXX/VLC/ios/
多謝LZ的奉獻~~~
【查看原文】
【253】【ios_VLC】【查看原文】
【247】【dispatch_after延時改變約束】
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// 當事件觸發時,改變其constant值,而後調用約束所在的對象的 layoutIfNeeded方法,固定的~ 例如:
_topView.collectionViewHeightConstraint.constant = 50;
// self.leftMarginConstraint.constant = 100;
// self.widthConstraint.constant = 200;
[UIView animateWithDuration:2.0 animations:^{
[self.view layoutIfNeeded];
[_topView layoutIfNeeded];
}];
});
【246】【this class is not key value coding-compliant for the key HeightConstraint】
問題:
this class is not key value coding-compliant for the key HeightConstraint
緣由:
在IB上拖線時的時候,有多的 ,刪除掉便可
解答:
【227】【ios_數組中放枚舉】
NSInteger _btnTagArr[4] = {ContactSelectBtnChatting,ContactSelectBtnTel,isTeacher?ContactSelectBtnLeave:ContactSelectBtnDetail};
【226】【實時得到webView的contentSize】
iOS 如何計算UIWebView的ContentSize
首選要等UIWebView加載內容後,而後在它的回調方法裏將webview的高度Height設置足夠小,就設置爲1吧,由於這樣才能用
sizeThatFits才能計算出webview得內容大小
- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
CGRect frame = aWebView.frame;
frame.size.height = 1;
aWebView.frame = frame;
CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero];
frame.size = fittingSize;
aWebView.frame = frame;
NSLog(@"size: %f, %f", fittingSize.width, fittingSize.height);
}
UIWebView計算高度 (2013-10-09 14:48:39)轉載▼
標籤: uiwebview 高度 計算 sizethatfits 分類: ios
第一種:
- (void)webViewDidFinishLoad:(UIWebView *)webView{
float height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] floatValue];
//document.body.scrollHeight
}
第二種:
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
CGRect frame = webView.frame;
CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
frame.size = fittingSize;
webView.frame = frame;
}
另一種
- (void)viewDidLoad {
[super viewDidLoad];
webview.delegate = self;
[webview loadHTMLString:@"
fdasfda
" baseURL:nil];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString *output = [webview stringByEvaluatingJavaScriptFromString:@"document.getElementByIdx_x_x_x("foo").offsetHeight;"];
NSLog(@"height: %@", output);
}
【224】【popping動畫演示】【進入網址】
【223】【第3方集成支付】【進入網址】
【222】【IOS7新特性之XCODE】【進入網址】
【218】【變量名和類型相同時的異常錯誤】
FilterCtrl *FilterCtrl = [[FilterCtrl alloc]init];
這樣命名變量,會報錯,提示:沒有聲明alloc方法。。。。
【217】【定義枚舉】
// 定義一個枚舉
typedef enum {
// 返回按鈕
FootViewBtnTypeBack,
// 個人
FootViewBtnTypeMine,
// 寫評論
FootViewBtnTypeWriteComment,
// 查看評論
FootViewBtnTypeReadComment,
// 關注、取消關注
FootViewBtnTypeAttention,
// 更多按鈕
FootViewBtnTypeMore
} FootViewBtnType;
【216】【scrollView滾動方向】
向上拉時,contentOffset.y爲正
向下拉時,contentOffset.y爲負
滾動判斷用到的變量:
typedef void (^ScrollBlock)(void);
// 向上滾動時的block
@property (nonatomic,strong) ScrollBlock scrollUpBlock;
// 向下滾動時的block
@property (nonatomic,strong) ScrollBlock scrollDownBlock;
// 滾動判斷
CGFloat startY;
BOOL isNowUp;
BOOL isDown;
BOOL isUserDrag;
#pragma mark - 滾動,新增,顯示,隱藏
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
// 開始時,標記置真
isUserDrag = YES;
// 記錄一下開始滾動的offsetY
startY = scrollView.contentOffset.y;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
// 結束時,置flag還原
isUserDrag = NO;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// 只有用戶drag時,才進行響應
if(isUserDrag){
// 實時
// 判斷一下,併發出通知
CGFloat newY = scrollView.contentOffset.y;
if(startY - newY >0){
// 說明向上滾動
if(!isNowUp){
//經過block告訴外部控制器
if(_scrollUpBlock){
_scrollUpBlock();
}
isNowUp = YES;
isDown = NO;
}
}else if(startY - newY<0){
// 說明向下滾動
if(!isDown){
//經過block告訴外部控制器
if(_scrollDownBlock){
_scrollDownBlock();
}
isDown = YES;
isNowUp = NO;
}
}
startY = scrollView.contentOffset.y;
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
if (_scrollDownBlock && self.tableView.contentSize.height - (self.tableView.contentOffset.y+self.tableView.bounds.size.height) < 1) {
_scrollDownBlock();
return;
}
if(_scrollUpBlock){
_scrollUpBlock();
isNowUp = YES;
isDown = NO;
return;
}
}
【214】【MJRefresh的github】【點擊下載】
【211】【如何設置appIcon】【點擊targets--->general--->use asset catalog】【查看原文】
【210】【DLog】
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif
【209】【特效濾鏡】【點擊下載】
【208】【往模擬器裏添加照片的最簡單的方法:直接把照片拖到模擬器上就能夠了】
【202】【OCR圖像識別】【能夠實現相似taobao客戶端掃描銀行卡號的功能】【查看原文】
【201】【Not a git repository】
fatal: Not a git repository (or any of the parent directories): .git
解決辦法:git init 便可
【199】【第3方_VKPlayer播放器】【進入網址】
【198】【pod install報錯 版本不兼容】【VKVideoPlayerTests` (iOS 5.0) is not compatible with `Expecta (0.3.2)` which,解決方法:將項目deployment改高一點如:6.1便可】
【197】【CardI掃描卡沒有反應】【 card.io only scans 5 card types (MasterCard, Visa, Discover, American Express, JCB),後面是stackoverflow的解答】【進入網址】 【查看原文】
【196】【沒法在真機運行,XCode提示ineligible device】【解決辦法:在targets---->build settings---->iOS Deployment Target選擇iOS6.1或者更低的版本】
【195】【正則NSPredicate檢查中文】
// 檢查漢字,YES表明全是漢字
- (BOOL)isHanziCheck:(NSString *)str
{
// NSString *regex = @"[a-zA-Z\u4e00-\u9fa5][a-zA-Z0-9\u4e00-\u9fa5]+";
NSString *regex = @"[\u4e00-\u9fa5]{2,8}";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if(![pred evaluateWithObject: str]){
/*
//此動畫爲在頂上顯示文字
[MPNotificationView notifyWithText:@"暱稱只能由中文、字母或數字組成"
andDuration:0.5];
*/
return NO;
}
return YES;
}
【186】【判斷包含字符串NSRange】
NSRange range = [requestURLStr rangeOfString:@"sg31.com"];
if (range.length > 0) {
}
或者
if(range.location !=NSNotFound){
}
【184】【SDWebImage默認會永久緩存一張圖片】【但若是同一個url下的圖片是變化的,那暫時想到的是用內存緩存,[imgView sd_setImageWithURL:url placeholderImage:imgPlace options:SDWebImageCacheMemoryOnly];】
【180】【URL Schemes打開app】【進入網址】
【179】【URL Schemes打開app】【進入網址】
【165】【UILabel顯示:標題。。。張數,設置NSLineBreakByTruncatingMiddle便可】
【162】【UserDefault寫入的目錄是:/var/mobile/Applications/Library/Preferences/com.beyond.testUserD.plist】
【161】【自動定位:中國浙江省杭州市西湖區西溪街道文二路下寧巷3-1號, 中國浙江省杭州市西湖區西溪街道文二路下寧巷3-1號 @ <+30.28138170,+120.14211600> +/- 100.00m, region (identifier <+30.28138150,+120.14211600> radius 49.29) <+30.28138150,+120.14211600> radius 49.29m】
【160】【自動定位:No. 3-1 Xianing Alley, No. 3-1 Xianing Alley, Wen'er Road Xixi Residential District, Xihu Hangzhou, Zhejiang China @ <+30.28138170,+120.14211600> +/- 100.00m, region (identifier <+30.28138150,+120.14211600> radius 49.29) <+30.28138150,+120.14211600> radius 49.29m】
【80】【打開模擬器】【XCode-->Open Developer Tool-->Simulator】
【79】【Unable to determine simulator device to boot】【緣由:XCode不知道選擇哪個模擬器去運行app. 解決方法:退出全部XCode和模擬器,若還不行,就重啓mac】
【78】【錯誤installAppearanceSwizzlesForSetter】【緣由是:[[UINavigationBar appearance] setTranslucent:NO]在iOS8中才有, 解決辦法:#define IOS8 [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 if(IOS8 && [UINavigationBar conformsToProtocol:@protocol(UIAppearanceContainer)]) { [[UINavigationBar appearance] setTranslucent:NO]; }】
【71】【判斷tableView滾動到了最後一行】【self.tableView.contentSize.height =contentOffset+bounds.size.height】
【61】【Cell中,先執行這個- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier,再執行這個-(void)awakeFromNib;】
【60】【AutoLayout中,如何讓ImageView保持固定的寬高比?例如1:1】【先將imageViewframe手動寫成:寬20,高20,再勾選Aspect Ratio添加寬高比約束】【查看原文】