跳到主要內容

發表文章

目前顯示的是 10月, 2017的文章

[iOS] 取得外部IP

  - ( NSString *)externalIPAddress {     // see https://stackoverflow.com/questions/27708887/objective-c-how-to-get-the-public-ip-address-of-the-device/27709110#27709110     // http://myipdoc.com/ip.php     NSString *publicIP = [ NSStringstringWithContentsOfURL :[ NSURLURLWithString : @"https://icanhazip.com/" ] encoding : NSUTF8StringEncodingerror : nil ];     publicIP = [publicIP stringByTrimmingCharactersInSet :[ NSCharacterSetnewlineCharacterSet ]];     return publicIP;   }

[iOS] Status Br Style

From  https://stackoverflow.com/questions/45372550/preferredstatusbarstyle-is-not-working If you want to set status bar style, application level then set  UIViewControllerBasedStatusBarAppearance  to  NO  in your  .plist  file. And in your  appdelegate >  didFinishLaunchingWithOptions  add following ine. [ UIApplication sharedApplication ] setStatusBarStyle : UIStatusBarStyleLightContent animated : YES ]; if you wan to set status bar style, at view controller level then follow these steps: Set the  UIViewControllerBasedStatusBarAppearance  to  YES  in the  .plist  file, if you need to set status bar style at UIViewController level only. In the viewDidLoad add function -  setNeedsStatusBarAppearanceUpdate override preferredStatusBarStyle in your view controller. - - ( void ) viewDidLoad { [ super viewDidLoad ]; [ self setNeedsStatusBarAppearanceUpdate ]; } - ( UIStatusBarStyle ) preferredStatusBarStyle { return UIStatusBarStyleLightContent ; }