presentedViewController
和presentingViewController
他们分别是被present的控制器和正在presenting的控制器。好比说,控制器A和B,[A presentViewController B animated:YES completion:nil];
那么A相对于B就是presentingViewController,B相对于A是presentedViewController,即这个时候 app
B.presentingViewController = A;测试
A.presentedViewController = B;字体
这两个属性仍是颇有用的,能够用来判断当前控制器是被present出来的仍是push进来的.动画
咱们开发中,可能会遇到某个界面比较复杂,要进行多个界面的切换,若是把这些界面切换全都放在该界面中,控制器代码很是臃肿不说,控制起来也比较麻烦,这个时候我建议用不一样的控制器来表示不一样的界面,而后将这些界面经过addChildViewController添加到控制器的子控制器中,而后经过系统提供的方法进行切换,至于这种方法怎么用,你们看下官方文档就知道了。ui
注意!! 宏定义必需要放在 import 引入头文件以前!
this
//define this constant if you want to use Masonry without the 'mas_' prefix #define MAS_SHORTHAND //define this constant if you want to enable auto-boxing for default syntax #define MAS_SHORTHAND_GLOBALS #import "Masonry.h"
//UINavigationBar背景透明 [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; //UINavigationBar去掉底部边线 [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
之前有看到过别人家的app, 点击tableview cell会跳转到两一个控制器, 当从下一个控制器返回时候, cell的选中效果会有一个渐变的取消选中的过程, 之前以为挺好奇的,单也一直没机会研究下, 其次公司只有我一个iOSer没人交流..... 总之今天才看到, 原来就是一个属性的事情.UITableViewController有一个专门的属性用来能够控制这个, 本身来实现的话, 实际上是在viewWillAppear:
方法里面调用tableView的方法取消选中效果, 以下:atom
//两行代码的事情, so easy NSIndexPath *selectedIndexpath = [self.tableView indexPathForSelectedRow]; [self.tableView deselectRowAtIndexPath:selectedIndexpath animated:YES];
主要问题是, 默认是按照一倍图来绘制的, 可是在retain屏上显示就会致使失真, 解决就是, 建立 UIGraphics
时候, 根据屏幕的分辨率来来建立, 以下:.net
UIGraphicsBeginImageContextWithOptions(size, NO, [[UIScreen mainScreen] scale]);
code
- (UIImage *)circleImageWithWidth:(double)width { CGSize size = CGSizeMake(width, width); // 开始图形上下文 UIGraphicsBeginImageContextWithOptions(size, NO, [[UIScreen mainScreen] scale]); // 得到图形上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); // 设置一个范围 CGRect rect = CGRectMake(0, 0, width, width); // 根据一个rect建立一个椭圆 CGContextAddEllipseInRect(ctx, rect); // 裁剪 CGContextClip(ctx); // 将原照片画到图形上下文 [self drawInRect:rect]; // 从上下文上获取剪裁后的照片 UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); // 关闭上下文 UIGraphicsEndImageContext(); return newImage; }
- (CGPoint)convertPoint:(CGPoint)point toView:(nullable UIView *)view; - (CGPoint)convertPoint:(CGPoint)point fromView:(nullable UIView *)view;
首先, 我认可这个简单的问题纠结了我很久, 今天偶然间发现了解决方案.orm
问题是, tableViewCell默认状况下选中时候会有一个选中效果, 大概是背景灰色, 而我看到不少应用都是, 选中时候有选中的效果,而后自动的变成非选中状态, 就这么个简单的问题, 前段时间也想了好久, 想到的方法是, 点击时候选中, 而后在viewWillAppear:方法中取消选中状态, 通常状况下仍是能够用的, 可是若是点击cell不须要跳转而是弹出对话框, 就有问题了, 今天发现的更好的方法就是, 在 didSelectRowAtIndexPath:
方法中添加一行代码, 以下:
// 选中一行后立刻取消选中 [tableView deselectRowAtIndexPath:indexPath animated:YES];
这样, cell被选中以后立刻回开始执行取消选中状态的动画. 好了 完美解决!!
http://download.csdn.net/detail/walden00/9611802
[self.navigationItem.rightBarButtonItem setTintColor:[UIColor whiteColor]]; [self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:14],NSFontAttributeName, nil] forState:UIControlStateNormal];
@property(nonatomic) UITextFieldViewMode clearButtonMode; // sets when the clear button shows up. default is UITextFieldViewModeNever
clearButtonMode = 1;
CGFloat codeSpeedBlock (void (^block)(void)) { mach_timebase_info_data_t info; if (mach_timebase_info(&info) != KERN_SUCCESS) return -1.0; uint64_t start = mach_absolute_time (); block (); uint64_t end = mach_absolute_time (); uint64_t elapsed = end - start; uint64_t nanos = elapsed * info.numer / info.denom; return (CGFloat)nanos / NSEC_PER_SEC; }