原创 button 設置文字左對齊

// button.titleLabel.textAlignment = NSTextAlignmentLeft; 這句無效 button.contentHorizontalAlignment = UIControlCon

原创 tabBarController 點擊某個按鈕不生效

//tabBarController 點擊某個按鈕不生效 #pragma mark UITabBarControllerDelegate - (BOOL)tabBarController:(UITabBarController *)ta

原创 tabbarcontroller的tabbar的顯示與隱藏

以導航爲控制 項目中一般都會用到 TabBar 這個控件,需求是 TabBar在主界面正常顯示,但Push到下一級界面時則需要隱藏,Pop回來的時候又需要顯示。 1、如下代碼代碼雖然能實現功能,但其操作繁瑣又無動畫效果,一般不用在此

原创 iOS中UISearchBar(搜索框)使用總結

iOS中UISearchBar(搜索框)使用總結 初始化:UISearchBar繼承於UIView,我們可以像創建View那樣創建searchBar     UISearchBar * bar = [[UISearchBar 

原创 長按手勢

//這裏是初始化長按手勢 longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc]

原创 獲取autolayout約束後的控件

//獲取autolayout約束後的控件 [view layoutIfNeeded];

原创 tabbarcontroller獲取tabbaritem當前下標對應的navigationcontroller

AppDelegate *delegate = [[UIApplication sharedApplication]delegate]; NSArray *views = delegate.tabController.viewContro

原创 iOS判斷網絡狀態

(一).Reachability 添加源文件及Framework Apple 的官方例子 Reachability 中介紹了獲取、檢測設備當前網絡狀態的方法。在你的程序中,需要把該工程中的Reachability.h 和 Reachab

原创 xcode8 修改的xib文件在xcode7,7.3.1上無法運行解決方案

最近xCode8 和 iOS10 相繼出來,團隊中有人使用xcode8 來開發工程; 他們提交代碼後,我們發現使用xcode8 修改的xib文件,在xcode7,7.3.1上無法運行: 解決方法如下: 1、右鍵點擊該xib文件

原创 單獨設置圓角

UIBezierPath *topmaskPath = [UIBezierPath bezierPathWithRoundedRect:topView.bounds byRoundingCorners:UIRectCornerTopL

原创 Xcode出現unable to boot the simulator和an internal error occurred.editing functionality may be limited

在終端下輸入以下指令: sudo mkdir /private/tmp sudo chmod 0777 /private/tmp 會報錯,是沒有權限,要按照以下方法執行: 重啓Mac,按住command+R(不動,等進度條加載完

原创 iOS模態出一個半透明的ViewControlle

UIViewController * vc = [[UIViewController alloc]init]; // 在present一個viewController時會需要一個提供背景的viewController,設置

原创 iOS方法中加閉包參數

-(void)requestByPhp:(NSString *)urlStr dic:(NSDictionary *)dic success:(void(^)(NSDictionary * dic))success fail:(void(

原创 iOS改變webView的文字大小

在webView的delegate回調方法 - (void)webViewDidFinishLoad:(UIWebView *)webView;中寫上一下語句即可 //字體大小 [webView stringByEvaluatingJ

原创 group樣式的tableView 改變第一組頂部距離

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 0.1; }