<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    一點一滴,編程人生

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      69 隨筆 :: 0 文章 :: 25 評論 :: 0 Trackbacks

    #

    文章出處:http://blog.csdn.net/iukey

    UIKit提供了一組控件:UISwitch開關、UIButton按鈕、UISegmentedControl分段控件、UISlider滑塊、UITextField文本字段控件、UIPageControl分頁控件。

    控件是對UIView派生類的實用增強及補充,并可以直接附著于導航欄、表格單元,甚至更大的對象。

    這些控件的基類均是UIControl,而UIControl派生自UIView類,所以每個控件都有很多視圖的特性,包括附著于其他視圖的能力。所有控件都擁有一套共同的屬性和方法。

    所以學習控件,我們先學習UIControl。

    屬性

    enabled

    控件默認是啟用的。要禁用控件,可以將enabled屬性設置為NO,這將導致控件忽略任何觸摸事件。被禁用后,控件還可以用不同的方式顯示自己,比如變成灰色不可用。雖然是由控件的子類完成的,這個屬性卻存在于UIControl中。

    selected

    當用戶選中控件時,UIControl類會將其selected屬性設置為YES。子類有時使用這個屬性來讓控件選擇自身,或者來表現不同的行為方式。

    contentVerticalAlignment

    控件如何在垂直方向上布置自身的內容。默認是將內容頂端對其,對于文本字段,可能會改成UIControlContentVerticalAlignmentCenter。對于這個字段,可以使用下列諸值:

    1. UIControlContentVerticalAlignmentCenter  
    2. UIControlContentVerticalAlignmentTop  
    3. UIControlContentVerticalAlignmentBottom  
    4. UIControlContentVerticalAlignmentFill  
    contentHorizontalAlignment

    水平對齊方式,可以只用下列值:

    1. UIControlContentHorizontalAlignmentCenter  
    2. UIControlContentHorizontalAlignmentTop  
    3. UIControlContentHorizontalAlignmentBottom  
    4. UIControlContentHorizontalAlignmentFill  

    事件通知

    UIControl類提供了一個標準機制,來進行事件登記和接收。這令你可以指定你的控件在發生特定事件時,通知代理類的一個方法。如果要注冊一個事件,可以使用addTarget方法:

    1. [ myControl addTarget: myDelegate   
    2.             action:@selector(myActionmethod:)  
    3.             forControlEvents:UIControlEventValueChanged ];  
    事件可以用邏輯OR合并在一起,因此可以再一次單獨的addTarget調用中指定多個事件。下列事件為基類UIControl所支持,除非另有說明,也適用于所有控件。

    UIControlEventTouchDown

    單點觸摸按下事件:用戶點觸屏幕,或者又有新手指落下的時候。

    UIControlEventTouchDownRepeat

    多點觸摸按下事件,點觸計數大于1:用戶按下第二、三、或第四根手指的時候。

    UIControlEventTouchDragInside

    當一次觸摸在控件窗口內拖動時。

    UIControlEventTouchDragOutside

    當一次觸摸在控件窗口之外拖動時。

    UIControlEventTouchDragEnter

    當一次觸摸從控件窗口之外拖動到內部時。

    UIControlEventTouchDragExit

    當一次觸摸從控件窗口內部拖動到外部時。

    UIControlEventTouchUpInside

    所有在控件之內觸摸抬起事件。

    UIControlEventTouchUpOutside

    所有在控件之外觸摸抬起事件(點觸必須開始與控件內部才會發送通知)。

    UIControlEventTouchCancel

    所有觸摸取消事件,即一次觸摸因為放上了太多手指而被取消,或者被上鎖或者電話呼叫打斷。

    UIControlEventTouchChanged

    當控件的值發生改變時,發送通知。用于滑塊、分段控件、以及其他取值的控件。你可以配置滑塊控件何時發送通知,在滑塊被放下時發送,或者在被拖動時發送。

    UIControlEventEditingDidBegin

    當文本控件中開始編輯時發送通知。

    UIControlEventEditingChanged

    當文本控件中的文本被改變時發送通知。

    UIControlEventEditingDidEnd

    當文本控件中編輯結束時發送通知。

    UIControlEventEditingDidOnExit

    當文本控件內通過按下回車鍵(或等價行為)結束編輯時,發送通知。

    UIControlEventAlltouchEvents

    通知所有觸摸事件。

    UIControlEventAllEditingEvents

    通知所有關于文本編輯的事件。

    UIControlEventAllEvents

    通知所有事件。

    除了默認事件以外,自定義控件類還可以用0x0F000000到0x0FFFFFFF之間的值,來定義他們自己的時間。

    要刪除一個或多個事件的相應動作,可以使用UIControl類的removeTarget方法。使用nil值就可以將給定事件目標的所有動作刪除:

    1. [ myControl removeTarget:myDelegate   
    2.                   action:nil  
    3.                   forControlEvents:UIControlEventAllEvents];  
    要取得關于一個控件所有指定動作的列表,可以使用allTargets方法。這個方法返回一個NSSet,其中包含事件的完整列表:

    1. NSSet* myActions = [myConreol allTargets ];  
    另外,你還可以用actionsForTarget方法,來獲取針對某一特定事件目標的全部動作列表:
    1. NSArray* myActions = [ myControl actionForTarget:UIControlEventValueChanged ];  

    如果設計了一個自定義控件類,可以使用sendActionsForControlEvent方法,為基本的UIControl事件或自己的自定義事件發送通知。例如,如果你的控件值正在發生變化,就可以發送相應通知,通過控件的代碼可以指定時間目標,這個通知將被傳播到這些指定的目標。例:

    1. [ self sendActionsForControlEvents:UIControlEventValueChanged ];  
    當委托類得到事件通知時,他將收到一個指向事件發送者的指針。下面的例子用于處理分段控件的事件,你的動作方法(action method)應遵循類似的處理方式:

    1. -(void) myAction:(id)sender{  
    2.        UISegmentedControl* control = (UISegmentedControl*)sender;  
    3.        if(control == myControl1){  
    4.         /*查詢控件得值*/  
    5.       /*響應myControl1的動作*/  
    6.        }  
    7. }  

    此文到此結束,如果你能耐心看看這篇文章,對你后面具體的控件會有事半功倍的效果。
    posted @ 2012-04-28 17:21 writegull 閱讀(2912) | 評論 (1)編輯 收藏

    保存你的私鑰,轉移到其它系統

    將你的私鑰安全的保存,如果你需要在多臺電腦上開發或者重裝你的操作系統的。如果沒有私鑰,那么將無法再Xcode簽名或者在apple設備上測試應用。當一個CSR被生成,Keychain Access應用在你的登錄keychain里面生成一個私鑰,這個私鑰是和你的用戶賬戶關聯的,如果在系統重裝的時候是無法重新生成的。如果你希望在多個系統上做開發或者測試,那么你需要在所有你工作的系統之上導入你的私鑰。

    1、 導出私鑰和數字證書是為安全保存和能夠在多臺電腦上進行工作。打開Keychain Access應用選擇’KEY’分類。

    2、 右鍵點擊和你iphone開發證書關聯的私鑰,并在彈出菜單中選擇導出選項。

    3、 使用(.p12)保存包含了你個人信息的鑰匙。

    4、 你將會被提示創建一個密碼。

    現在可以通過.p12文件在不同系統之間傳輸。雙擊.p12在其他系統上進行安裝。輸入你在step4輸入的密碼。

    posted @ 2012-04-27 10:40 writegull 閱讀(629) | 評論 (0)編輯 收藏

       在編譯好的真機版目錄下的.app文件,至于生成真機可以運行的app的方法,有兩種方式,一種是交99美元獲得一個證書,另外一種是破解的方式,在此不再詳述,本文假設你已經生成了真機上可以運行的app包了(app包實際上是一個文件夾

       假設此安裝包的名稱是 hello.app,點擊右鍵,選擇 顯示包內容,這樣就可以打開這個hello.app文件夾了,在此文件夾中有一個info.plist文件,打開它,新增加一個名為SignerIdentity的key字段,內容為Apple iPhone OS Application Signing。

    然后將.app拖到itunes就生成ipa了.默認名字應該是hello.ipa

    如果要將此ipa分發出去,可以在itunes中的hello.ipa文件上點擊鼠標右鍵,選擇 在finder中顯示,就可以得到生成后的ipa安裝文件了

    posted @ 2012-04-26 09:50 writegull 閱讀(1186) | 評論 (0)編輯 收藏

    1.在Windows下打開/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/SDKSettings.plist ,找到CODE_SIGNING-REQUIRED 將它對應的值改為NO。

    2.打開Xcode創建/打開一個項目,把Code signing identity和Any ios 對應的值改為Don’t Code Sign 

    3.Build and Run!Enjoy!
    posted @ 2012-04-26 09:42 writegull 閱讀(241) | 評論 (0)編輯 收藏

    1.程序圖標app icon ------ 普屏 icon.png[57*57] 視網膜屏icon@2x.png[114*114]

    iPhone開發中經常用到的控件尺寸大集合

    Sizes of iPhone UI Elements


    iPhone UI 設計的一些標準尺寸1 - 懶得喘氣 - 懶得喘氣的博客
    ElementSize (in points)
    Window (including status bar)320 x 480 pts
    Status Bar
    (How to hide the status bar)
    20 pts
    View inside window 
    (visible status bar)
    320 x 460
    Navigation Bar44 pts
    Nav Bar Image /
    Toolbar Image
    up to 20 x 20 pts (transparent PNG)
    Tab Bar49 pts
    Tab Bar Iconup to 30 x 30 pts (transparent PNGs)
    Text Field31 pts
    Height of a view inside 
    a navigation bar
    416 pts
    Height of a view inside 
    a tab bar
    411 pts
    Height of a view inside 
    a navbar and a tab bar
    367 pts
    Portrait Keyboard height216 pts
    Landscape Keyboard height140 pts
    Points vs. Pixels
    The iPhone 4 introduced a high resolution display with twice the pixels of previous iPhones. However you don't have to modify your code to support high-res displays; the coordinate system goes by points rather than pixels, and the dimensions in points of the screen and all UI elements remain the same.
    iOS 4 supports high resolution displays (like the iPhone 4 display) via the scale property on UIScreen, UIView, UIImage, and CALayer classes. If the object is displaying high-res content, its scale property is set to 2.0. Otherwise it defaults to 1.0.
    All you need to do to support high-res displays is to provide @2x versions of the images in your project. See the checklist for updating to iOS4 or Apple documentation for Supporting High Resolution Screens for more info.
    Adjusting Sizes
    Click here to see how to adjust View Frames and Bounds.
    Additional References
    Table 8-1  Custom icons and images

    Description

    Size for iPhone and iPod touch (in pixels)

    Size for iPad (in pixels)

    Guidelines

    Application icon (required for all apps)

    57 x 57

    114 x 114 (high resolution)

    72 x 72

    “Application Icons”

    App Store icon (required for all apps)

    512 x 512

    512 x 512

    “Application Icons”

    Launch image (required for all apps)

    320 x 480

    640 x 960 (high resolution)

    For portrait:

    • 768 x 1004

    For landscape:

    • 1024 x 748

    “Launch Images”

    Small icon for Spotlight search results and Settings (recommended)

    29 x 29

    58 x 58 (high resolution)

    50 x 50 for Spotlight search results

    29 x 29 for Settings

    “Small Icons”

    Document icon (recommended for custom document types)

    22 x 29

    44 x 58 (high resolution)

    64 x 64

    320 x 320

    “Document Icons”

    Web clip icon (recommended for web apps and websites)

    57 x 57

    114 x 114 (high resolution)

    72 x 72

    “Web Clip Icons”

    Toolbar and navigation bar icon (optional)

    Approximately 20 x 20

    Approximately 40 x 40 (high resolution)

    Approximately 20 x 20

    “Icons for Navigation Bars, Toolbars, and Tab Bars”

    Tab bar icon (optional)

    Approximately 30 x 30

    Approximately 60 x 60 (high resolution)

    Approximately 30 x 30

    “Icons for Navigation Bars, Toolbars, and Tab Bars”

    Newsstand icon for the App Store (requiredfor Newsstand apps)

    At least 512 pixels on the longest edge

    At least 512 pixels on the longest edge

    “Newsstand Icons”

    posted @ 2012-04-26 09:31 writegull 閱讀(8968) | 評論 (0)編輯 收藏

    如果我們在Hibernate中需要查詢多個表的不同字段,如何來獲取結果呢?
    有兩種方式:
    1、 對各個字段分別轉化成對應類型,如下:

    Java代碼
    1. Query session.createQuery(select members, classInfo.className "    
    2.     from Members members, ClassInfo classInfo "    
    3.     where members.level classInfo.classCode ");    
    4.   
    5. List result q.list();    
    6. Iterator it result.iterator();    
    7. while (it.hasNext())    
    8.    Object[] tuple (Object[]) it.next();    
    9.    Members members (Members) tuple[ 0 ];    
    10.    String className (String) tuple[ 1 ];    
    11.  
     

    2、構造自己的復合類型,如下:

    Java代碼
    1. Query session.createQuery(select new NewMembers(members, classInfo.className) "    
    2.     from Members members, ClassInfo classInfo "    
    3.     where members.level classInfo.classCode ");  

    當然我們需要有一個NewMembers類和相應的構造方法。

    posted @ 2012-04-24 09:34 writegull 閱讀(553) | 評論 (0)編輯 收藏

    有時我們寫個代碼開源出來給別人用時,會被其他開發者抱怨編譯不了,很多情況是版本的問題,尤其現在ARC的出現后關于weak,strong的問題讓人頭疼。
    有個開源代碼這里做的很不錯,就是MBProgressHUD
    看下他是怎么做的:

    1. #ifndef MB_STRONG
    2. #if __has_feature(objc_arc)
    3.     #define MB_STRONG strong
    4. #else
    5.     #define MB_STRONG retain
    6. #endif
    7. #endif
    8.  
    9. #ifndef MB_WEAK
    10. #if __has_feature(objc_arc_weak)
    11.     #define MB_WEAK weak
    12. #elif __has_feature(objc_arc)
    13.     #define MB_WEAK unsafe_unretained
    14. #else
    15.     #define MB_WEAK assign
    16. #endif
    17. #endif

    非ARC的retain,相當于ARC的strong
    iOS5的ARC中weak能在銷毀時自動賦值nil,這是iOS4.x上使用ARC不具備,所以用的unsafe,非ARC自然是assign

    posted @ 2012-04-23 15:49 writegull 閱讀(1425) | 評論 (0)編輯 收藏

    release 是將內存引用計數-1  nil 直接賦值為0   除非這個指針指向的空間被釋放  否則就是內存泄露

    nil是表示0x0,可以理解為空指針。release是釋放內存。
    例如:你開辟了一塊內存p=[[nsobject alloc] init]; 這個時候p是指向這塊內存區域的,如果你直接p=nil,會造成這塊內存沒有被釋放,內存泄露。 如果[p release]釋放了內存,但是p還是指向這個內存地址,如果在操作p會出現EXC_BAD_ACCESS。正確的做法應該是釋放后,把p指向nil
    posted @ 2012-04-20 17:40 writegull 閱讀(484) | 評論 (0)編輯 收藏

    概述

    UIView對象在屏幕中定義了一個復雜區域和界面來管理這個區域的內容

    視圖的職責:
    畫圖和動畫。
    布局和子視圖管理。

    事件處理。

     

    1、創建一個視圖對象

    CGRect viewRect = CGRectMake(10,10,100,100);
    UIView* myView = [[UIView alloc] initWithFrame:viewRect];
    [self.window addSubview :myView];//將視圖作為子視圖添加到window中

    2、動畫

    改變一些視圖屬性將會使用到動畫,改變屬性時創建一個動畫,用于給用戶傳遞在較短時間內的變化。UIView類做了動畫展現的大部分工作,但是你仍然需要聲明哪種屬性改變的時候,你需要動畫效果。有兩種不同的類型來初始化動畫
    下面的UIView屬性支持動畫:
    frame,bounds,center,transform,alpha,backgroundColor,contentStretch
    在iOS 4之后,使用block-based動畫方法(推薦使用)
    使用 開始/提交方式(begin/commit)

    3、管理視圖的層次結構

    superview屬性:
    subviews屬性:
    window屬性:
    -addSubview方法
    -bringSubviewToFront:(UIView *)veiw方法,將view視圖移到層次結構的最頂端,使得其得以展示
    -sendSubviewToBack:(UIView *)veiw方法,和上面方法正好相反
    -removeFromSupview方法,
    -insertSubview:(UIView *)view atIndex:(Interger)index方法
    -insertSubview:(UIView *)view aboveSubview(UIView *)siblingView 方法
    -insertSubview:(UIView *)view belowSubview(UIView *)siblingView 方法
    -exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2方法
    -isDescendantOfView:(UIView *)view方法,判斷view是不是指定視圖的子視圖

    4、子視圖的布局(layout)

    -layoutSubviews方法,這個方法,默認沒有做任何事情,需要子類進行重寫
    -setNeedsLayout方法
    -layoutIfNeeded方法,立即對子視圖進行布局

    5、畫/更新視圖

    -drawRect:(CGRect)rect方法
    -setNeedsDisplay
    -setNeedsDisplayInRect:(CGRect)invalidRect方法

    6、以塊展現動畫的方式(animating views with block)

    + animateWithDuration:delay:options:animations:completion:
    + animateWithDuration:animations:completion:
    + animateWithDuration:animations:
    + transitionWithView:duration:options:animations:completion:

    + transitionFromView:toView:duration:options:completion:

    7、在視圖和坐標系統之間轉換

    -convertPoint:toView
    -convetPoint:fromView
    -convertRect:toView
    -convertRect:fromView

    8、跟蹤視圖相關的改變

    -didAddSubview:
    -willRemoveSubview:
    -willMoveToSuperview
    -didMoveToSuperview
    -willMoveToWindow:
    -didMoveToWindow
    posted @ 2012-04-20 10:37 writegull 閱讀(9679) | 評論 (0)編輯 收藏

         摘要: 目前做的一個項目里用到了提示音,但是又不想添加提示音到庫里,便開始研究調用系統自帶的提示音,最后終于找到了。開始在CC上查發現好像很多人都在問,但沒人回答,我就把自己查到的東西和寫的一個demo給大家分享下吧首先要在工程里加入Audio Toolbox framework這個庫,然后在需要調用的文件里#import <AudioToolbox/AudioToolbox.h>最后在需要播...  閱讀全文
    posted @ 2012-04-16 14:23 writegull 閱讀(1968) | 評論 (0)編輯 收藏

    僅列出標題
    共7頁: 上一頁 1 2 3 4 5 6 7 下一頁 
    主站蜘蛛池模板: 国产精品亚洲自在线播放页码| 亚洲国产成人久久精品99| 亚洲一卡2卡4卡5卡6卡残暴在线| 在线观看免费人成视频色| 国产尤物在线视精品在亚洲| 日韩亚洲变态另类中文| 91人成网站色www免费下载| 亚洲AV无码一区二区三区久久精品| 久久久久亚洲AV无码专区网站| 无码人妻丰满熟妇区免费| 亚洲人成色在线观看| 亚洲国产美女精品久久久久∴| 日韩免费一区二区三区在线播放| 国产91成人精品亚洲精品| 亚洲AV无码一区二区三区DV| 在线观看人成网站深夜免费| 精品久久久久久国产免费了| 亚洲av永久综合在线观看尤物| 亚洲国产综合精品中文字幕 | 久久嫩草影院免费看夜色| 33333在线亚洲| 亚洲国产精品碰碰| 91人成网站色www免费下载| 免费精品久久久久久中文字幕| 亚洲天天在线日亚洲洲精| 免费国产精品视频| 亚洲免费中文字幕| 中文字幕不卡高清免费| 亚洲日韩精品无码专区| 亚洲综合精品香蕉久久网97| 内射无码专区久久亚洲| 国产精品美女午夜爽爽爽免费| 免费看一区二区三区四区| 色www免费视频| 天堂亚洲国产中文在线| 久久久亚洲精品视频| 免费在线精品视频| 毛片a级三毛片免费播放| 日韩av无码久久精品免费| 国产精品无码永久免费888 | 麻豆安全免费网址入口|