先將imageViewframe手動寫成:寬20,高20,再勾選Aspect Ratio加入寬高比約束【查看原文】 【2015-03-23 11:29:04 by beyond】
self.tableView.contentSize.height =contentOffset+bounds.size.height【2015-03-23 15:27:43 by beyond】
緣由是:[[UINavigationBar appearance] setTranslucent:NO]在iOS8中才有, 解決的方法:#define IOS8 [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 if(IOS8 && [UINavigationBar conformsToProtocol:@protocol(UIAppearanceContainer)]) { [[UINavigationBar appearance] setTranslucent:NO]; }【2015-03-23 17:14:57 by beyond】
緣由:XCode不知道選擇哪個模擬器去執行app. 解決方法:退出所有XCode和模擬器,若還不行,就從新啓動mac【2015-03-23 17:24:04 by beyond】
XCode-->Open Developer Tool-->Simulator【2015-03-23 17:24:48 by beyond】
。。php
張數,設置NSLineBreakByTruncatingMiddle就能夠】【2015-03-24 15:43:37 by beyond】
html
但假設同一個url下的圖片是變化的。那臨時想到的是用內存緩存,[imgView sd_setImageWithURL:url placeholderImage:imgPlace options:SDWebImageCacheMemoryOnly];【2015-03-25 15:14:35 by beyond】
NSRange range = [requestURLStr rangeOfString:@"sg31.com"]; if (range.length > 0) { } 或者 if(range.location !=NSNotFound){ }【2015-03-25 16:41:50 by beyond】
// 檢查漢字,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; }【2015-03-27 10:14:24 by beyond】
解決的方法:在targets---->build settings---->iOS Deployment Target選擇iOS6.1或者更低的版本號【2015-03-30 09:36:17 by beyond】
card.io only scans 5 card types (MasterCard, Visa, Discover, American Express, JCB),後面是stackoverflow的解答【進入網址】 【查看原文】 【2015-03-30 11:34:15 by beyond】
VKVideoPlayerTests` (iOS 5.0) is not compatible with `Expecta (0.3.2)` which,解決方法:將項目deployment改高一點如:6.1就能夠【2015-03-30 11:35:52 by beyond】
fatal: Not a git repository (or any of the parent directories): .git 解決的方法:git init 就能夠【2015-03-30 11:58:48 by beyond】
可以實現類似taobaoclient掃描銀行卡號的功能【查看原文】 【2015-03-30 14:49:13 by beyond】
#ifdef DEBUG #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); #else #define DLog(...) #endif【2015-03-31 18:55:00 by beyond】
點擊targets--->general--->use asset catalog【查看原文】 【2015-04-01 14:53:43 by beyond】
向上拉時,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; } }【2015-04-02 11:41:05 by beyond】
// 定義一個枚舉 typedef enum { // 返回button FootViewBtnTypeBack, // 個人 FootViewBtnTypeMine, // 寫評論 FootViewBtnTypeWriteComment, // 查看評論 FootViewBtnTypeReadComment, // 關注、取消關注 FootViewBtnTypeAttention, // 不少其它button FootViewBtnTypeMore } FootViewBtnType;【2015-04-02 14:57:34 by beyond】
FilterCtrl *FilterCtrl = [[FilterCtrl alloc]init]; 這樣命名變量,會報錯,提示:沒有聲明alloc方法。【2015-04-02 15:04:13 by beyond】。ios
。git
。 github
iOS 怎樣計算UIWebView的ContentSize 分類: iPhone常見問題 2014-02-27 17:33 1754人閱讀 評論(0) 收藏 舉報 首選要等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); }【2015-04-03 15:46:30 by beyond】
NSInteger _btnTagArr[4] = {ContactSelectBtnChatting,ContactSelectBtnTel,isTeacher?【2015-04-03 17:01:13 by beyond】ContactSelectBtnLeave:ContactSelectBtnDetail}; web
問題: this class is not key value coding-compliant for the key HeightConstraint 緣由: 在IB上拖線時的時候。有多的 ,刪除掉就能夠 解答:【2015-04-07 11:14:44 by beyond】
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]; }]; });【2015-04-07 11:23:03 by beyond】
VLC for iOS 2.3.0 關於VLC配置問題,依據我的經驗整理了一下,但願能幫到需要的朋友。 官網連接:https://wiki.videolan.org/IOSCompile/ 百度雲盤連接:http://pan.baidu.com/s/1bnEOXPH password:ur4l 配置說明(百度雲盤) 官網依照說明操做就可以了僅僅是下載的地址是個谷歌的什麼站點,因此你懂得。 百度雲盤下載下來後需要配置下文件VLC/ios/External 這個目錄如下有六個文件(快捷方式):MediaLibraryKit,MobileVLCKit,PLCrashReporter,QuincyKit,gtl,upnpx 又一次配置下這六個文件路徑就可以用了,vlc源代碼是區分真機和模擬器的 終端配置路徑 一、在終端進入External目錄 二、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 三、路徑正確的話就沒問題了,ls -l 查看文件路徑 改動完畢後就可以啓動了VLC/iOS/VLC for iOS.xcodeproj 注意:我有時候配置正確路徑但是文件仍是報錯,這樣的狀況的話解壓又一次搞吧,臨時不知道怎麼處理。 SimplePlayback 這個是VLC在線播放的一個demo,路徑:VLC/ios/ImportedSources/VLCKit/Examples_iOS/SimplePlayback 項目直接拷貝出來不能用的,要配置下。 libMobileVLCKit.a 這個demo用到這個靜態庫。【查看原文】 【2015-04-08 17:05:30 by beyond】靜態庫區分真機和模擬器的。json
靜態庫我不太懂怎麼配置,搞了幾回沒搞定 只是有另外的辦法MobileVLCKit.framework這個不區分真機和模擬器的。 路徑:VLC/ios/ImportedSources/VLCKit/build 注意:Deployment target 要低於7.0 END 最後但願能幫到需要的朋友,不懂得可以聯繫我,qq:527993842,加好友請說明謝謝,由於工做緣由可能沒法及時回覆請見諒,而且我也是剛接觸vlc。c#
關鍵詞: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的奉獻~~~ segmentfault
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;【2015-04-08 17:29:42 by beyond】
死活不走代理方法: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); } 緣由多是:手機上拉高速設置欄中:豎排方向鎖定 :打開了【2015-04-09 11:13:39 by beyond】
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【2015-04-09 11:52:57 by beyond】
在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就能夠【2015-04-09 14:40:52 by beyond】
右上方----show the assistant edit ---- 選擇新窗體中manual最下方的Preview【2015-04-10 09:51:28 by beyond】
在使用時,假設在queue裏面的block運行過程當中,又調用了 indatabase方法,則會檢查 是否是同一個queue,假設是同一個queue會死鎖;緣由很是easy: 隊列裏面 放了一個block,該block又在 本隊列 後面放了一個 block; 從而:前一個block 裏面 調用了 後一個block,必須等後一個block運行完畢了。 前一個block纔會 出隊列; 然後一個block想要運行,則又必須先等 前一個block出隊列。 所以 死鎖。!【2015-04-16 10:49:41 by beyond】。!數組
解決方法:在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"); }
contentSize 必須明白指定。如label距離下方多少。距離右邊多少,這樣才幹夠 讓scrollView計算出contentSize【查看原文】 【2015-04-16 15:50:52 by beyond】
// 其它狀況,返回是數組 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.一、對於被包括的模塊。臨時剔除 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]; } } // 一、對數組按GroupTag排序 NSArray *sortDesc = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"FGroupTag" ascending:YES]]; NSArray *sortedArr = [tempdictArr sortedArrayUsingDescriptors:sortDesc]; // DLog(@"排序後的數組:%@",sortedArr); // 二、對數組進行分組,按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]; } } } // 三、遍歷 對每一組 進行排序 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【2015-04-17 11:39:14 by beyond】
- (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]; // 其它初始化方法 }【2015-04-17 13:44:36 by beyond】
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【進入網址】 【2015-04-20 10:30:15 by beyond】
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);【2015-04-21 15:31:01 by beyond】
viewdidload tableView.rowHeight = UITableViewAutomaticDimension; tableView.estimatedRowHeight = 10; cellForRow [cell layoutIfNeeded];【2015-04-21 15:37:29 by beyond】
project--->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; }【2015-04-23 09:58:25 by beyond】
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];【2015-04-23 17:22:19 by beyond】