• objective c


    hold down the control key; click the File's  Owner icon in thme main nib window

    and keep the mouse button down.Drag away the File's Owner icon toward the

    View window. A bule guideline should appear. Keep dragging util your cursor is over the label in the View window Even though you won't be able to see the lael

    it willl magicallyapper once you over it

    and a small gray menu like the one show in Figure should pop up.

    Select statusText from the gray menu.

    telling Interface Builder that you want to connect one of the File's Owner's

    outlets to this Object when the nib file is loaded. In this case, the file's owner

    is the class Button_FunViewController, and the

    oulet point to the label,

    Specifying Actions

    using the connections inspector.

    c2 

    More User Interface Fun

    to tie a button control to a text label. controls to a whole new level.

    an image view, a slider,two different text fields,

    a segmented control, a couple of switches, and an IOS

    button that looks more like, well, an ios button.

    use the view hierarchy to group multiple items under a common parent

    view and make manipulating the interface at runtime easier.

    set and retrieve the values of various controls , both by using outlets

    and by using the sender argument of our action methods.

    using action sheets  to force the user to make a choice and alerts to give the user important

    the use of stretchable images

    break our application into pieces,implementing our piece at a time and bouncing back and

    forth between Xcode and the IOS simulator, testing each piece before we move

    on to the nex

    Dividing the process of building a complex interface into smaller

    chunks make it much less intimidating ,

    A Screen Full of Controls

    The logo at the top of the iPhone screen is an image view,

    and in this application , it does nothing more than display a static image

    alphanumeric text and  one that allows only numers.

    Below the text fields ia a slider.

    segmented control and two switches.

    an action sheet pops up,asking users if thy really meant to tap the button.

    Active, and Passive Controls

    Uer interface controls come in three basic forms: active and passive

    active controls.push them, and something happens, a piece of code fires

    work in a passive manner, simply holding on to a value that the user has entered until you're

    ready for it. dont't trigger action methods, but the user can interact with

    them and change their values.  text field on a web page.

    the vast majority of web page text fields are simpl containers

    for data that's submitted to the server when you click the sbmit button.

    many of the available controls can be used in all both ways, depending on your needs.

    All IOS controls are subclasses of UIControl and ,because of that are capable of triggering action methods

    Creating the Application

    Control Fun.

    The image must be imported into Xcode before it will be available for us inside IB,

    import it now

    itis a .png image sized correctly for the space available

    Add the image to the Resources folder of your project, by dragging the image form the Finder to

    the Resources folder
    Determin Outlets

    figure out which of these objects requires an outlet

    remerber that outlets must be defined in your controller class's header file before you can connect them to anything in the ib edior.

    The image view is just a static image.

    that image won't change while our application is running.

    As a result. It does not require an outlet.

    If we want to change the image or any of its characteristics at runtime

    we would need an outlet. That is not the case here.

    use an outlet,

    #import <UIKit/UIKit.h>

    @interface Control_FunViewController : UIViewController {

      UITextField *nameField;

      UITextField *numberField;

    }

    @property (nonatomic, retain) IBOutlet UITextField *nameField;

    @property(nonatomic, retain) IBOutlet UITextField *numberField;

    @end

    add our @synthesize directives to Control_FunViewController.m

    #import "Control_FunViewController.h"

    @implementation Control_FunViewController

    @synthesize nameField;

    @synthesize numberField;

    careful about memor.

    with the retain keyword, release them both in our dealloc method

    - (void)dealloc {

      [nameField release];

      [numberField release];

      [super dealloc];

    }

    Determing Actions

    Building the Interface

    select library from the Tools menu.

    Resize the image View

    the same size as your image.

    to press c= to select Size to Fit from the layout menu

    hierarchical View Mode button in the main nib window.

    find and select the image view when it comes to resizing

    hold down the option key

    The Mode Attribute

    pop-up menu labeled Mode

    how the image will be aligned inside the view and whether

    it will be scaled to fit.

    display the same image at multipage sizes, generally it's etter to have

    multiple copies of the image at different sizs in your project

    The Alpha Slider

    Alpha, how transparent your image is: how much of what's beneath

    it shows through.

    spend processor cycles calculating transparency.

    Ignore the Background

    The Tag Attribute

    numeric value that you can set that will tag along with your image view

    Tags provide an easy,language-independent way of identifying objects on your inerface.

    a single action method to handle all five buttons.

    button's title   tags will never change, so if you set a tag value here in Inetvace

    Builder, you can then use that as a fast and reliable way to check

    which control was passed into an action method in the sender argument.

    The Drawing checkboxes

    The Drawing Checkboxes

    a series of Drawing checkboxes.  labeled Opaque

    Adding the Text Field

    The Text Field Inspector Settings

    default value for this field.

    Placeholder, specify a bit of text that will be displayed

    in gray inside the text field,but only when the field has no

    value.

    Type in the text Type in a name as the placeholder for this text field.

    the appearance of your text field,

    to look a certain way.

    Background and Disabled field and leave them blank.

    Border four buttons.

    the text field's edge will be drawn.

    Clear When Editing Begins checkbos    happens

    when the user touches this field.

    any value that was previously in this field will get deleted , and the user will

    start with an empty field. If this box is unchecked, the prevos vlue

    will stay in the field, and the user will be able to edit it.

    Text Color field is a combination of a color well

    Adjust to Fit checkbox specifies whether the size

    of the text should shrink if the text firld is reduced in size

    Text Input Traits

    how th keyboard will look and behave when this text field is being used. Since we're expecting

    a name, let's chagen the Capitalize drop-down to Words, which

    will cause every word to be automatically capitalized, which

    is what you typically want with names.

    Return Key pop-up to Done

  • 相关阅读:
    40 +必不可少的前端Web开发备忘单
    web前端开发必读的HTML5的书籍
    Java String的内存机制
    使用C#通过Oracle.DataAccess连接Oracle,部署时需要注意版本问题
    CI(CodeIgniter)的"Disallowed Key Characters."异常处理
    开源软件许可协议简介
    读《考拉小巫的英语学习日记》有感
    vi的复制、粘贴、查找、删除等常用命令
    读《马云创业启示录》有感
    jQuery ajax 同步失效?
  • 原文地址:https://www.cnblogs.com/yushunwu/p/2678201.html
Copyright © 2020-2023  润新知