be better off
原文解釋: used to give advice or an opnion, to be a better position/situation
中文解釋: 較佳狀況, (對於某事來說)是較為明智的
已下為兩個例句:
A. Have you decide what to do after you graduate?
Will 發表在 痞客邦 留言(0) 人氣(4,842)
drag on
原文解釋: if an event or situation drags on, it continues for too long
and you dont know when is going to end
中文解釋: 拖延, 拖時間
已下為兩個例句:
A. How long has that MC been speaking?
Will 發表在 痞客邦 留言(0) 人氣(882)
walk on egg shells
原文解釋: to be very careful about how you behave with someone,
because they are wasily upset or made angry.
中文解釋: 蛋殼相當脆弱, 若想走在蛋殼上頭必得警慎小心, 正處於一個微妙且危險的地位
已下為兩個例句:
A. How is your daughter doing?
Will 發表在 痞客邦 留言(0) 人氣(2,164)
泡沫排序核心思維:每次比較兩個相鄰元素, 順序錯誤就交換
若有n個數字進行排序, 進行排序從第一個元素進行相鄰數字比較,
所以只需進行n - 1次操作即可完成,
程式碼如下:
#include <stdio.h>
int main(int argc, const char * argv[]) {
//n控制輸入元素之次數, tmp為暫存變數
int bubbleSortArray[100], n, tmp;
scanf("%d", &n);
for(int i = 0; i < n ; i++)
scanf("%d", &bubbleSortArray[i]);
for (int i = 0; i < n - 1; i++) //n個數排序, 只需n-1次
{
for (int j = 0; j <= n - 1; j++) //從陣列第一個元素比較到n-1個
{
if (bubbleSortArray[j] > bubbleSortArray[j + 1])
{
//大小互換
tmp = bubbleSortArray[j];
bubbleSortArray[j] = bubbleSortArray[j + 1];
bubbleSortArray[j + 1] = tmp;
}
}
}
//輸出結果
for(int i = 1; i < n ; i++)
printf("%d ", bubbleSortArray[i]);
return 0;
}
Will 發表在 痞客邦 留言(0) 人氣(663)
此範例為使用checkBox紀錄使用者登入之帳號密碼相關資訊,
google了許多範例都閹割了一些必要功能,
例如重新開啟app後rememberMe功能就失效之類等等,
重新reWork測試後為功能較完整的一份code如下所示
Xml布局檔
Will 發表在 痞客邦 留言(0) 人氣(179)
此範例先將動畫要用之圖片複製近xcode中,
接著使用一個array並存放圖片,
之後創建一個imageView物件顯示動畫窗格,
再透過[imageView startAnimating]此方法播放動畫, 程式碼如下
Will 發表在 痞客邦 留言(0) 人氣(1,119)
此範例作用為圖片翻轉會產生out of memory問題, 藉由inSampleSize去調整縮放比例則可以解決此問題
package com.example.photoRatation;
import android.R.string;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
public class MainActivity extends Activity {
/* this comment use for test */
public ImageView imageView1;
int deg = 0;
@SuppressLint("SdCardPath")
@Override
protected void onCreate(Bundle savedInstanceState) {
Runtime rt = Runtime.getRuntime();
long maxMemory = rt.maxMemory();
Log.d("00000000000", "maxMemory:" + Long.toString(maxMemory));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView1 = (ImageView) findViewById(R.id.imageView1);
String sourceFilePath = "file:///mnt/sdcard/DCIM/100MEDIA/IMAG0005.jpg";
String newFilePath = "file:///mnt/sdcard/DCIM/100MEDIA/";
photoRotation(sourceFilePath, newFilePath, deg);
}
public String photoRotation(String sourceFilePath, String newFilePath, int deg) {
try {
if (sourceFilePath == null) {
return null;
}
Uri uri = Uri.parse(sourceFilePath);
ContentResolver cr = this.getContentResolver();
deg = deg - 90;
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = android.graphics.Bitmap.Config.RGB_565;
options.outHeight = 1840;
options.outWidth = 3264;
options.inSampleSize = calculateInSampleSize(options, 32, 64);
Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri), null, options);
Matrix m = new Matrix();
int width = bitmap.getWidth();
int height = bitmap.getHeight();
m.setRotate(deg);
Bitmap bmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, m, false);
//imageView1.setImageBitmap(bmap);
newFilePath = bmap.toString();
//return newFilePath;
} catch (OutOfMemoryError ooe) {
ooe.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return newFilePath;
}
public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
// Calculate the largest inSampleSize value that is a power of 2 and
// keeps both
// height and width larger than the requested height and width.
while ((halfHeight / inSampleSize) > reqHeight
&& (halfWidth / inSampleSize) > reqWidth) {
inSampleSize *= 2;
}
}
return inSampleSize;
}
}
Will 發表在 痞客邦 留言(0) 人氣(301)
android app是由activity組成, 每個activity代表一個畫面, 也是一個可執行的獨立單元
此範例為簡易的activity頁面切換
1. 首先新增一專案, 此範例命名為MainActivity, 創建完成後執行file/new/other/android activty
新增activity, 命名為SecondActivity
Will 發表在 痞客邦 留言(0) 人氣(627)

此範例目的為滑動UISlider, 並顯示此音量控制元件的數值
1. stroryboard中加入slider, label
2. 加入程式關聯性
@property (weak, nonatomic) IBOutletUILabel *valueLabel;
property (weak, nonatomic) IBOutletUISlider *mySlider;
- (IBAction)sliderValueChange:(id)sender;
Will 發表在 痞客邦 留言(0) 人氣(444)
1. 開啟storyboard, 從元件褲拖曳一個Long Press Gesture Recognizer元件到view上,
並在viewcontroller.m檔中建立關聯性, 程式碼如下
@interfaceViewController ()
- (IBAction)handleLongPressGesture:(UILongPressGestureRecognizer *)sender;
@end
Will 發表在 痞客邦 留言(0) 人氣(887)