快速連結

2013年11月24日

iOS螢幕旋轉觸發自定義function (xcode 5)

資料來源與參考:官方:Supporting Multiple Interface Orientations

iOS6之前使用的旋轉函式已經無法使用了,而是使用-(NSUInteger)supportedInterfaceOrientations-(BOOL)shouldAutorotate來配合旋轉。
但是如果在旋轉後要呼叫自定程序去處理自定界面呢?

2013年11月21日

進入XCode 5時代後,怎麼無法Archive

好不容易生成Provisioning Profile檔案,試著Archive,卻發生報錯:
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “XXXX”, however, no such provisioning profile was found.
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0'
有兩個解決方案:
Provisioning Profile的設定更正
或是
使用文本編輯器修改xcodeproj檔案

2013年8月5日

讓另一個自定義ViewGoup物件能夠添加且顯示在自定義ViewGroup內

標題寫的很複雜,簡單來說就是──

我有一個自定義ViewGroup物件,稱為父親,要加入孩子,這孩子也是另外一個自定義ViewGroup物件。
雖然能夠成功addView進孩子,但是孩子卻羞澀的硬是不顯示出來。
──這不是孩子太過於害羞的問題!
而是你少告訴他你長多高多寬!

記得要在子自定義ViewGroup物件內的建構子中,加上:

this.setMinimumWidth(100);
this.setMinimumHeight(100);

2013年7月22日

背景圖無限重複祕技

使用以下圖片,拼成滿版背景的方法

在APP內拼成花花的背景:


2013年7月10日

讓你的View動起來──新版本

在4.0之前,讓View動作的語法如下:

    UIButton *button = [[UIButton alloc] init];
    CGRect frame = button.frame;
    frame.origin.x = 500; // new x coordinate
    frame.origin.y = 500; // new y coordinate

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration: 0.25];
    button.frame = frame;
    button.alpha = 0;
    [UIView commitAnimations];

2013年5月21日

對每個child作class確認

以下是程式碼:

for (var i:uint = 0; i < this.numChildren;i++){
  var child = this.getChildAt(i);
  if (child is SimpleButton){
     trace(child,"is SimpleButton");
  }
}

2013年3月2日

取得網址的參數


$.urlParam = function(name){
 var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
 if (!results) { return 0; }
 return results[1] || 0;
}


來源:Get URL Parameters with jQuery | Improved

2013年2月26日

改‧TouchImageView

原本我使用的版本找不到了,類似的在此:Pinching Zoom in android Image View or Bitmap
另外一個的版本則是這個:MikeOrtiz / TouchImageView
WrapMotionEvent與EclairMotionEvent程式碼我就沒有放上來了,直接到第一個連結複製即可。
我這裡參考許多文章,在TouchImageView.java內增加了放大縮小、邊界判定。

2013年2月23日

讓ViewGroup建立實體物件

當想要建立ViewGroup物件時,卻發現不能用ViewGroup直接建立物件,因為他是abstract(抽象)類型,必須要再建立一個實體類別去繼承ViewGroup。
實體類別的程式碼下收:

2013年2月20日

合併兩張圖片吧

上一次那個沒用,我就用合併的方式。
這次有用了XD
我是用左右並排的方式,依照不同需要可以隨意更改新Bitmap的長寬~注意一下drawBitmap的數值就好!

private Bitmap mergeBitmap(Bitmap firstBitmap, Bitmap secondBitmap) {
        int newWidth = firstBitmap.getWidth() + secondBitmap.getWidth();
        Bitmap bitmap = Bitmap.createBitmap(newWidth, firstBitmap.getHeight(),
                firstBitmap.getConfig());
        Canvas canvas = new Canvas(bitmap);
        canvas.drawBitmap(firstBitmap, 0, 0, null);
        canvas.drawBitmap(secondBitmap, firstBitmap.getWidth(), 0, null);
        canvas.save(Canvas.ALL_SAVE_FLAG);//保存  
 canvas.restore();
        return bitmap;
}

在ImageView中一次顯示多張圖片的技巧

在ImageView中一次顯示兩張圖片的技巧,話說,我還沒成功過!(欸)
可是來源的討論串是有人成功囉!
來源:overlay two images in android to set an imageview

private DoubleImage(Bitmap bm1, Bitmap bm2){
  ImageView imgView = new ImageView(this);
  Drawable[] layers = new Drawable[2];
  layers[0] = new BitmapDrawable(getResources(),bm1);
  layers[1] = new BitmapDrawable(getResources(),bm2);
  LayerDrawable layerDrawable = new LayerDrawable(layers);
  imgView.setImageDrawable(layerDrawable);
}

2013年2月19日

iOS系列產品解析度規格表參考

筆記一下相關規格表,來自於 Xcode Custom Icon and Image Creation Guidelines

UIImage 縮放

想讓UIImage進行縮放的程式碼:

// grab the original image
    UIImage *originalImage = [UIImage imageNamed:@"myImage.png"];
    // scaling set to 2.0 makes the image 1/2 the size. 
    UIImage *scaledImage = 
                [UIImage imageWithCGImage:[originalImage CGImage] 
                              scale:(originalImage.scale * 2.0)
                                 orientation:(originalImage.imageOrientation)];


注意,scale = 2.0是讓圖縮一半哦!

2013年2月18日

又更新網站(三天兩頭就來一次)


網站更版,這是使用PHP來結合資料庫應用,裝了很多JS,接下來就是更改塔羅牌商品頁面囉!
使用JS列表:

ViewPager + PagerAdapter + AsyncTask 讓讀圖更順利

最近開始進行下載圖片,然後放入ViewPager去翻頁顯示,但是因為圖片是存在SD卡內,卻不知道為什麼會讀取很慢(已經壓縮到100k左右了)。
由於讀取緩慢,所以滑動頁面的時候就會卡住,整個快哭了。
後來想到可以使用AsyncTask分流讀取,果然順暢許多!

2013年1月8日

筆記android中在空無一物的activity中取得viewGroup


ViewGroup _p = (ViewGroup) getWindow().getDecorView().findViewById(android.R.id.content);

ViewGroup _p = (ViewGroup) this.findViewById(android.R.id.content);

2013年1月6日

圖片規格筆記(隨時都會增加筆記)

通常「只有原生」跟Cocos2D會有點差異,依照差異類型作分類: