摘要:/** * 打开照相机 */ - (void)openCamera { if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) return; UIImagePickerController *ipc = [[UIImageP...
阅读全文
摘要:/** * 根据图片名返回一张能够自由拉伸的图片 */ +(UIImage *)resizedImage:(NSString *)name { UIImage *image=[UIImage imageWithName:name]; return [image stretchableImageWithLeftCapWidth:image.size.width*0.5...
阅读全文
摘要:封装到 HMSearchBar.h / .m #import <UIKit/UIKit.h> @interface HMSearchBar : UITextField + (instancetype)searchBar; @end #import "HMSearchBar.h" @implement
阅读全文
摘要:#pragma mark - 实现这个方法来控制屏幕方向 /** * 控制当前控制器支持哪些方向 * 返回值是UIInterfaceOrientationMask* */ - (NSUInteger)supportedInterfaceOrientations { /** * UIInterfaceOrientationMaskPortrait : 竖屏...
阅读全文
摘要:// 监听slider滑动 - (IBAction)valueChnage:(UISlider *)sender; @property (weak, nonatomic) IBOutlet NJView *circleView; @end @implementation NJViewController - (IBAction)valueChnage:(UISlider *)sende...
阅读全文
摘要:// 该方法只有在通过代码创建控件的时候才会调用, 如果控件是通过xib或者storyboard创建出来的不会调用该方法- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifie
阅读全文
摘要:* UISwitch继承自UIControl,因此也能像UIButton一样监听一些事件,比如状态改变事件* UISwitch可以通过拖线监听状态改变* UISwitch可以通过addTarget:...方法监听状态改变- (void)addTarget:(id)target action:(SEL
阅读全文
摘要:● 除了push之外,还有另外一种控制器的切换方式,那就是Modal ● 任何控制器都能通过Modal的形式展示出来 ● Modal的默认效果:新控制器从屏幕的最底部往上钻,直到盖住之前的控制器为止 ● 以Modal的形式展示控制器 - (void)presentViewController:(UI
阅读全文
摘要:UITabBarController的简单使用 ● UITabBarController的使用步骤 ➢ 初始化UITabBarController ➢ 设置UIWindow的rootViewController为UITabBarController ➢ 根据具体情况,通过addChildViewCo
阅读全文
摘要:#pragma mark - UITextFieldDelegate // 返回NO代表着文本输入框不可以改变(不可以编辑) - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { r...
阅读全文
摘要:UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"确定要注销?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil]; [sheet showInView:self.vie...
阅读全文
摘要:默认情况下,模拟器的目录是隐藏的,要想显示出来,需要在Mac终端输入下面的命令 显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles Yes 隐藏Mac显示文件的命令:defaults write com.apple.finde
阅读全文
摘要:@interface NJTwoViewController () @end @implementation NJTwoViewController // 当控制器的view加载完毕就调用 - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Two
阅读全文
摘要:- (IBAction)back2Two:(id)sender { // 移除当前栈顶的控制器 [self.navigationController popViewControllerAnimated:YES]; } - (IBAction)back2root:(id)sender { // 移除除了栈底控制器的所有控制器 [self.navigationC...
阅读全文
摘要:● UINavigationController的使用步骤 ➢ 初始化UINavigationController ➢ 设置UIWindow的rootViewController为UINavigationController ➢ 根据具体情况,通过push方法添加对应个数的子控制器 ➢ 初始化UIN
阅读全文
摘要:MJViewController的view的创建 的方式的优先级 控制器view的延迟加载 ● 控制器的view是延迟加载的:用到时再加载 ● 可以用isViewLoaded方法判断一个UIViewController的view是否已经被加载 ● 控制器的view加载完毕就会调用viewDidLoa
阅读全文
摘要:● 先加载storyboard文件(Test是storyboard的文件名) UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Test" bundle:nil]; ● 接着初始化storyboard中的控制器 ➢ 初始化“初
阅读全文
摘要:● 控制器常见的创建方式有以下几种 ➢ 通过storyboard创建 ➢ 直接创建 NJViewController *nj = [[NJViewController alloc] init]; ➢ 指定xib文件来创建 NJViewController *nj = [[NJViewControll
阅读全文
摘要:// 程序启动完毕之后就会调用一次 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 1.创建UIWindow self.window = [[UIWindow alloc] initWithFr...
阅读全文