2011年1月19日

討厭的 EXC_BAD_ACCES

討厭的 EXC_BAD_ACCESS

相信有很多人遇過 EXC_BAD_ACCESS 的錯誤訊息,有時候進 debug 也查不出個所以然,這種記憶體的問題,不管在哪種開發工具都會遇到。

而 Xcode 有個 Zombie 的方式,可以指出哪裡出問題!


從 Xcode 左側,展開 Groups & Files 內的 Executables 分類,點選 Project 名稱的項目,按右鍵選 Get Info。

切換到 Arguments 的標簽頁,在底下 Variables to be set in environment 下方有個「+」與「-」,按下「+」後,在「Name」輸入 『NSZombieEnabled』,「Value」輸入『YES』。

以後只要有物件建立,Zombie 也會自動建立,這樣在 debug 過程,如果有錯誤訊息發生,也可以透過 Zombie 找到進一步的問題點。

2011年1月5日

[轉] iPhone Development 101: User Interface: Sizes of iPhone UI Elements

iPhone Development 101: User Interface:
Sizes of iPhone UI Elements


ElementSize (in pixels)
Window (including status bar)320 x 480px
Status Bar
(How to hide the status bar)
20 px
View inside window
(visible status bar)
320 x 460
Navigation Bar44 px
Nav Bar Image /
Toolbar Image
up to 20 x 20 px (transparent PNG)
Tab Bar49 px
Tab Bar Iconup to 30 x 30 px (transparent PNGs)
Text Field31 px
Height of a view inside
a navigation bar
416 px
Height of a view inside
a tab bar
411 px
Height of a view inside
a navbar and a tab bar
367 px
Portrait Keyboard height216 px
Landscape Keyboard height140 px

Viewing / Adjusting Sizes in Interface Builder

Sizes for specific UI elements (buttons, text fields, images, etc.) can be adjusted in the size panel of the Inspector window (↑⌘I):
iconshortcut
⌘3Size is the size and location (in X,Y coordinates) of the object on screen.
Size (and location) can also be adjusted programmatically:
[button setFrame:CGRectMake(x, y, width, height)];
The x, y position refers to the top left corner of the view being positioned.

Frame and Bounds

The frame is the outer container for the view - the position of the item within its enclosing superview. x is the distance left-right, where x = 0 is the left side. y is the distance up-down, where y = 0 is the top of the frame.
The bounds rectangle determines the origin and scale in the view's coordinate system within its frame rectangle. Setting this property changes the value of the frame property accordingly.
When you set the frame property, the size of the bounds property is set to match the size of the frame property. The center property is also adjusted to match the center point of the new frame.

Additional References