[PHP]json出力でunicodeエスケープしない
json出力でunicodeエスケープしない
header("Content-Type: application/json; charset=utf-8"); echo json_encode( $jsonStr , JSON_UNESCAPED_UNICODE);
json出力でunicodeエスケープしない
header("Content-Type: application/json; charset=utf-8"); echo json_encode( $jsonStr , JSON_UNESCAPED_UNICODE);
iOSのorientationchange時の処理順
画面サイズ変更 -> resize -> orientationchange
Androidのorientationchange時の処理順
orientationchange -> 画面サイズ変更 -> resize
又は 画面サイズ変更 -> resize -> orientationchange
※端末(Androidのバージョン?)によってはこの順番の時もある
よってjsで端末回転時の処理をする際は下記のようにする。
var oEventCount = 0; $(window).off('.ori').on('orientationchange.ori resize.ori',function(e){ oEventCount++; if(oEventCount < 2){ return; } oEventCount = 0; //do something });
・resizeイベントだけで済む場合もある。
・iOSの場合、スクロールでステータスバーが出たり引っ込んだりした時にresizeイベントが走る
こっちのほうが良い場合も
var oEventId; $(window).off('.ori').on('orientationchange.ori resize.ori',function(e){ clearTimeout(oEventId); oEventId = setTimeout(function(){ //do something },300); });
UIView Extension #4
var subviewsSortByTop:[AnyObject]{ get{ var w:[AnyObject] = self.getSubviews() w.sort { (v1:AnyObject, v2:AnyObject) -> Bool in return v1.origin.y < v2.origin.y } return w } }
UIView Extension #3
func goto(left:CGFloat,top:CGFloat, duration:CGFloat=0.4){ UIView.setAnimationBeginsFromCurrentState(true) UIView.animateWithDuration(NSTimeInterval(duration), delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in self.left = left self.top = top }, completion: { (finish:Bool) -> Void in } ) }
UIImageView Extension #1
extension UIImageView { var paintColor:String{ get{ return "" } set{ if self.image != nil { if newValue == "" { self.paintByTintColor = false }else{ self.tintColor = Drawer.getUIColorByColorHex(newValue, alpha: 1.0, luminanceScale: 1.0) self.paintByTintColor = true } } } } var paintByTintColor:Bool{ get{ return true } set{ if newValue { self.image = self.image!.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) }else{ self.image = self.image!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) } } } }
UIView Extension #2
var className:String{ get{ return NSStringFromClass(self.dynamicType).componentsSeparatedByString(".").last! } } var fileName:String{ get{ return __FILE__.componentsSeparatedByString("/").last! } }
UIView Extension #1
var left:CGFloat{ get{ return self.frame.origin.x } set{ self.frame = CGRectMake(newValue, self.frame.origin.y, self.frame.size.width, self.frame.size.height) } } var right:CGFloat{ get{ return self.frame.origin.x + self.frame.size.width } set{ self.frame = CGRectMake(newValue - self.frame.size.width, self.frame.origin.y, self.frame.size.width, self.frame.size.height) } } var top:CGFloat{ get{ return self.frame.origin.y } set{ self.frame = CGRectMake(self.frame.origin.x, newValue, self.frame.size.width, self.frame.size.height) } } var bottom:CGFloat{ get{ return self.frame.origin.y + self.frame.size.height } set{ self.frame = CGRectMake(self.frame.origin.x, newValue - self.frame.size.height, self.frame.size.width, self.frame.size.height) } }
GCD #2
func dispatch_async_global(block: () -> ()) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block) }
GCD #1
func dispatch_async_main(block: () -> (), delay: Double = 0) { if delay <= 0 { dispatch_async(dispatch_get_main_queue(), block) return } let d = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC))) dispatch_after(d, dispatch_get_main_queue()) { block() } }