跳到主要內容

發表文章

目前顯示的是 2018的文章

IOS Swift 擷取當前螢幕產生縮圖

         func screenshot() -> UIImage {             var imageSize = CGSize.zero                  let orientation = UIApplication.shared.statusBarOrientation             if UIInterfaceOrientationIsPortrait(orientation) {                 imageSize = UIScreen.main.bounds.size             } else {                 imageSize = CGSize(width: UIScreen.main.bounds.size.height, height: UIScreen.main.bounds.size.width)             }                  UIGraphicsBeginImageContextWithOptions(imageSize, false , 0 )             for window in UIApplication.shared.windows {                 window.drawHierarchy(in: window.bounds, afterScreenUpdates: true )             }                  let image = UIGraphicsGetImageFromCurrentImageContext()             UIGraphicsEndImageContext()             return image!         }

IOS Swift 在某路徑下產生檔案 txt json

語法:         func createFile(name: String , fileBaseUrl: URL ){             let manager = FileManager . default                          let file = fileBaseUrl. appendingPathComponent (name)             print ( "文件: \ ( file )" )             let exist = manager. fileExists (atPath: file. path )             if !exist {                 let data = Data (base64Encoded: "aGVsbG8gd29ybGQ=" ,options:. ignoreUnknownCharacters )                 let createSuccess = manager. createFile (atPath: file. path ,contents:data,attributes: nil )                 print ( "文件產生结果: \ ( createSuccess )" )             }         }                  //新建test.txt文件         let manager = FileManager . default         let urlForDocument = manager. urls ( for: . documentDirectory ,                                            in:. userDomainMask )         let url = urlForDocument[ 0 ]         createFile (name: "projects/new1.

暫存

Documents : 存放应用程序产生的数据,会被itunes备份同步 Library : 包含两个子目录:Caches 和 Preferences Preferences:包含应用程序的偏好设置文件。您不应该直接创建偏好设置文件,而是应该使用NSUserDefaults类来取得和设置应用程序的偏好,会被itunes备份同步. Caches:用于存放应用程序专用的支持文件,保存应用程序再次启动过程中需要的信息,不会被itunes备份同步。 tmp : 存放临时数据,当不在用时应该删除掉临时文件,系统也有可能在程序不运行时删除该文件夹下内容 ##获取目录方法 ###Home目录 //获取沙盒主目录路径 var homeDir=NSHomeDirectory() println ( "\(dirHome)" ) ###Documents目录 //获取Documents目录路径 var paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory .DocumentDirectory , NSSearchPathDomainMask .UserDomainMask , true) var documentsDirectory = paths[ 0 ] as! String println( "\(documentsDirectory)" ) 或者相对Home路径 var documentsDirectory = NSHomeDirectory ().stringByAppendingPathComponent( "Documents" ) println ( " \(documentsDirectory) " ) ###Library目录 // 获取Library目录路径 var paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory .LibraryDirectory , NSSearchPathDomainMask .UserDom

IOS Swift 根目錄路徑

語法: 根目錄 RootDirectory  =  NSHomeDirectory () Documnets let   Documnets   = NSHomeDirectory () + "/Documents/" Library let   Library    =  NSHomeDirectory () +  "/Library" Cache let   Cache    =  NSHomeDirectory () +  "/ Cache " tmp let   tmp    =  NSHomeDirectory () +  "/ tmp "

iOS開發 出錯 EXC_BAD_ACCESS main.m

 EXC_BAD_ACCESS 出現 EXC_BAD_ACCESS 在 main.m 修改成以下代碼 int main( int argc, char * argv[]) {         @autoreleasepool {                          @try {         int retVal = UIApplicationMain (argc, argv, nil , @"AppDelegate" );<----這行報出錯         return retVal;     }             @catch (NSException * __unused exception) {               NSLog ( @"Error Main Log :%@" , exception);             }     } }

Android Studio RUN APK 出現 default activity not found

出現 default activity not found 在 android manifest.xml內新增藍色部分,主要是因為找不到 LAUNCHER <activity android :name= ".MainActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="com.ashzheng.puzzle.MainActivity"/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>

Android Studio How can I fix "Design editor is unavailable until a successful build

Android Studio 出錯  "Design editor is unavailable until a successful build" 確認紅圈處無ERROR即可

android studio 出現 DELETE_FAILED_INTERNAL_ERROR

DELETE_FAILED_INTERNAL_ERROR 下午 05:17 Failed to finalize session : Unknown failure (Error: java.lang.SecurityException: Requires android.permission.ASEC_CREATE permission) Disable Instant Run Settings>Build, Execution, Deployment>Instant Run

Version 1.6.0_65 of the JVM is not suitable for this product.

Version 1.6.0_65 of the JVM is not suitable for this product. install  http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html