Bits of knowledge,bitsofknowledge
如何擷取當前裝置的系統版本!!!
[[[UIDevice currentDevice] systemVersion] floatValue]
擷取App版本
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
// app名稱
//NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app build版本
//NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
如何更改導航控制器push動畫時間?
A控制器push到B控制器,push動畫過渡時間大約為0.3秒。希望改成0.7秒! pop出來也改成0.7秒!請問該如何??
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (self.viewControllers.count > 0) {
viewController.hidesBottomBarWhenPushed = YES;
CATransition *animation = [CATransition animation];
animation.duration = 0.5f;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:animation forKey:nil];
[super pushViewController:viewController animated:NO];
return;
}
[super pushViewController:viewController animated:YES];
}
iOS介面設定豎屏,個別介面強制橫屏
- (BOOL)shouldAutorotate 當前viewcontroller是否支援轉屏
- (NSUInteger)supportedInterfaceOrientations;當前viewcontroller支援哪些轉屏方向 -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation當前viewcontroller預設的螢幕方向
#import <UIKit/UIKit.h>
@interface CustomNavigationController : UINavigationController
@property(nonatomic)NSUInteger orietation; #import "CustomNavigationController.h"
@interface CustomNavigationController ()
@end
@implementation CustomNavigationController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) {
} return self; }
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. }
- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
//當前viewcontroller是否支援轉屏 -(BOOL)shouldAutorotate { return NO; }
//當前viewcontroller支援哪些轉屏方向 -(NSUInteger)supportedInterfaceOrientations{ //return UIInterfaceOrientationMaskLandscapeRight; return self.orietation; }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != self.orietation); } |
iOS推崇使用png格式的 說這樣不會失幀
imageWithContentsOfFile這個方法?跟imagewithname的區別嗎
imagewithname會使用系統緩衝,對重複載入的圖片速度會快。效果好
imageWithContentsOfFile不會緩衝
小圖 用 imageName 大圖 還有 做動畫的圖片 使用imageWithContentsOfFile