iOS
共 6 篇文章
使用系统默认UITableViewCell使用时的heightForRowAtIndexPath:indexPath方法
iOS项目开发中使用系统默认的UITableViewCell时,Delegate中的方法- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;须慎用。 项目中使用系统默认的UITableViewCell: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *tableV…
2014-10-13 14:13 · iOS · iOS · uitableviewcell
iOS后台运行示例代码
iOS获取有限的后台运行时间 // AppDelegate.h文件 @property (assign, nonatomic) UIBackgroundTaskIdentifier backgroundUpdateTask; // AppDelegate.m文件 - (void)applicationDidEnterBackground:(UIApplication *)application { [self beingBackgroundUpdateTask]; // 后台运行代码 [self endBackgroundUpdateTask]; } - (void)beingBackgro…
2014-08-21 14:23 · iOS · iOS · 后台运行
layoutSubviews调用时机
原文 :以下情况下会被调用: 1、init初始化不会触发layoutSubviews; 2、addSubview会触发layoutSubviews; 3、设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化; 4、滚动一个UIScrollView会触发layoutSubviews; 5、旋转Screen会触发父UIView上的layoutSubviews事件; 6、改变一个UIView大小的时候也会触发父UIView上的layoutSubviews事件;
2014-04-01 13:14 · iOS · layoutSubviews
扩展UIDevice来监测网络连接
《The iPhone Developer's Cookbook》 没什么好说的,直接上代码: 1、UIDevice+Reachability.h: #import <UIKit/UIKit.h> @interface UIDevice (Reachability) + (BOOL) networkAvailable; + (BOOL) activeWLAN; + (BOOL) activeWWAN; @end 2、UIDevice+Reachability.m: #import <SystemConfiguration/SystemConfiguration.h> #include <ar…
2013-11-07 17:40 · iOS · Objective-C
判断网络是否连接
iOS开发中判断网络连接的操作步骤如下: 1、添加framework,SystemConfiguration.framework; 2、倒入文件: #import <SystemConfiguration/SystemConfiguration.h> #include <netdb.h> 3、判断方法: - (BOOL) connectedToNetwork { // Create zero addy struct sockaddr_in zeroAddress; bzero(&zeroAddress, sizeof(zeroAddress)); zeroAddress.sin_len = …
2013-11-07 17:32 · iOS · Objective-C
视图切换的方式
1、利用NavigationController切换 切换: - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; 返回: - (UIViewController *)popViewControllerAnimated:(BOOL)animated; 2、覆盖View达到切换效果 切换: - (void)addSubview:(UIView *)view; 返回: - (void)removeFromSuperview; 3、利用Present系列方法 切换: - (voi…
2013-11-01 15:59 · iOS · iOS · 页面切换