Some Basic UI Elements

Discussion in 'iOS Development' started by godogshomie, Oct 1, 2008.

  1. godogshomie

    godogshomie New Member

    Joined:
    Nov 19, 2007
    Messages:
    558
    Likes Received:
    3
    UITextField

    [OBJC]UITextField *username =[[UITextField alloc] initWithFrame:CGRectMake(24.5, 65, 270, 30)];
    username.delegate=self;
    username.textAlignment=UITextAlignmentCenter;
    username.borderStyle=UITextBorderStyleRoundedRect;
    username.placeholder=@"Username\n";
    username.autocorrectionType=UITextAutocorrectionTypeNo;
    username.autocapitalizationType=UITextAutocapitalizationTypeNone;
    [self.view addSubview:username];
    [/OBJC]

    UIActionSheet
    [OBJC]
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle

    Please Register or Log in to view images

    "This is where the information will go"
    delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
    otherButtonTitles

    Please Register or Log in to view images

    "Email", @"Tech Support",@"Website",@"Cancel", nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    actionSheet.destructiveButtonIndex = 3; // make the second button red (destructive)
    [actionSheet showInView:self.view];
    [actionSheet release];
    [/OBJC]

    Selecting a button on UIActionSheet
    [OBJC]
    - (void)actionSheet

    Please Register or Log in to view images

    UIActionSheet *)actionSheet clickedButtonAtIndex

    Please Register or Log in to view images

    NSInteger)buttonIndex
    {
    if (buttonIndex == 0){
    // do stuff
    }
    }
    [/OBJC]


    UISwitch
    [OBJC]
    UISwitch *switchIt = [[UISwitch alloc] initWithFrame:CGRectZero];
    switchIt.on=NO;
    [self.contentView addSubview:switchIt];
    [/OBJC]

    UILabel
    [OBJC]
    UILabel *usernameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    usernameLabel.text=@"Personal Location Checkin";
    usernameLabel.adjustsFontSizeToFitWidth=YES;
    [self.contentView addSubview:usernameLabel];
    [/OBJC]

    UISearchBar
    [OBJC]
    UISearchBar *mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
    mySearchBar.delegate = self;
    mySearchBar.showsCancelButton = YES;
    mySearchBar.barStyle=UIBarStyleBlackOpaque;
    mySearchBar.placeholder=@"Enter Name or Phone Number";
    mySearchBar.keyboardType=UIKeyboardTypeNamePhonePad;


    [self.view addSubview: mySearchBar];
    [/OBJC]

    UIView
    [OBJC]
    UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    contentView.backgroundColor = [UIColor grayColor];
    self.view = contentView;
    [contentView release];
    [/OBJC]

    UITableView
    [OBJC]
    UITableView *myBeaconsTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 45, self.view.bounds.size.width, 375)];
    myBeaconsTableView.delegate=self;
    myBeaconsTableView.dataSource=self;

    [self.view addSubview:myBeaconsTableView];
    [/OBJC]

    Or to make a grouped table view (like in preferences)

    [OBJC]
    UITableView *settingsTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 40, self.view.bounds.size.width, 375) style:UITableViewStyleGrouped];
    settingsTableView.delegate=self;
    settingsTableView.dataSource=self;
    [self.view addSubview:settingsTableView];
    [/OBJC]

    UINavigationBar
    Plain no Title
    [OBJC]
    myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
    [self.view addSubview:myNavBar];
    [/OBJC]
    Black Opaque (no title)
    [OBJC]
    myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
    myNavBar.barStyle=UIBarStyleBlackOpaque;
    [self.view addSubview:myNavBar];
    [/OBJC]
    Black Translucent (no title)
    [OBJC]
    myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
    myNavBar.barStyle=UIBarStyleBlackTranslucent;
    [self.view addSubview:myNavBar];
    [/OBJC]

    To add title and other buttons

    [OBJC]
    UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle

    Please Register or Log in to view images

    "Around Me"];
    [myNavBar pushNavigationItem: navItem];
    [/OBJC]

    To add buttons with image
    [OBJC]
    refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action

    Please Register or Log in to view images

    selector(action

    Please Register or Log in to view images

    ];
    [navItem setLeftBarButtonItem:refreshButton];
    [/OBJC]

    Add button with Text
    [OBJC]
    refreshButton = [[UIBarButtonItem alloc] initWithTitle

    Please Register or Log in to view images

    "About Us" style:UIBarButtonItemStyleBordered target:self action

    Please Register or Log in to view images

    selector(action

    Please Register or Log in to view images

    ];
    [navItem setRightBarButtonItem:refreshButton];
    [/OBJC]

    How to add comments
    [OBJC]
    When you want to add a comment about a line of code you do this

    // Comment

    To do a multi-lined comment you would do this

    /* This
    is
    multi-lined
    comment
    */
    [/OBJC]

    UIWebView
    [OBJC]
    dailyWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 45, self.view.bounds.size.width, 375)];
    dailyWebView.delegate=self;
    dailyWebView.scalesPageToFit=YES;
    [dailyWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString

    Please Register or Log in to view images

    "http://www.google.com"]]];
    [self.view addSubview:dailyWebView];
    [/OBJC]

    UITextView
    [OBJC]
    UITextView *textView = [[[UITextView alloc] initWithFrame:frame] autorelease];
    textView.textColor = [UIColor blackColor];
    textView.font = [UIFont fontWithName

    Please Register or Log in to view images

    "Helvetica" size:15];
    textView.delegate = self;
    textView.backgroundColor = [UIColor whiteColor];

    textView.text = @"TEXT TO GO IN HERE";
    [self.view addSubView:textView];
    [/OBJC]


    UISegmentedControl
    [OBJC]
    UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
    [NSArray arrayWithObjects:
    [UIImage imageNamed

    Please Register or Log in to view images

    "segment_check.png"],
    [UIImage imageNamed

    Please Register or Log in to view images

    "segment_search.png"],
    [UIImage imageNamed

    Please Register or Log in to view images

    "segment_tools.png"],
    nil]];
    frame = CGRectMake( 0,
    0,
    self.view.bounds.size.width,
    35);
    segmentedControl.frame = frame;
    [segmentedControl addTarget:self action

    Please Register or Log in to view images

    selector(segmentAction

    Please Register or Log in to view images

    forControlEvents:UIControlEventValueChanged];
    segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
    segmentedControl.selectedSegmentIndex = 1;
    [self.view addSubview:segmentedControl];
    [/OBJC]

    UIAlertView
    [OBJC]
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle

    Please Register or Log in to view images

    "UIAlertView" message

    Please Register or Log in to view images

    "Your message"
    delegate:self cancelButtonTitle

    Please Register or Log in to view images

    "Cancel" otherButtonTitles

    Please Register or Log in to view images

    "Button1", @"Button2", nil];
    [alert show];
    [alert release];
    [/OBJC]

    This is just some UI elements that can be added through code

    NO NDA!!!
  2. eric_chaos

    eric_chaos Well-Known Member

    Joined:
    Nov 4, 2007
    Messages:
    3,746
    Likes Received:
    35
    Device:
    iPhone 4 (Black)
    wow!

    Im speechless.
  3. murphmanny

    murphmanny Banned

    Joined:
    Sep 19, 2007
    Messages:
    5,250
    Likes Received:
    3
    thanx
    a lot man
    this helps out a lot
    nice job
  4. crizh4x

    crizh4x Active Member

    Joined:
    Sep 19, 2007
    Messages:
    4,474
    Likes Received:
    17
    Device:
    2G iPod touch
    Now for which released app is this? You aren't exactly following the *new* NDA
  5. godogshomie

    godogshomie New Member

    Joined:
    Nov 19, 2007
    Messages:
    558
    Likes Received:
    3
    this is in all my projects.
  6. jordskee

    jordskee Member

    Joined:
    Apr 28, 2008
    Messages:
    681
    Likes Received:
    0
    Device:
    iPhone 4 (Black)
    that looks very complicated
  7. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    Programming isn't a simple task.

    Well, I suppose using a hold-your-hand set of APIs on an integrated device is a little different, but we'll save that for another day.
  8. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    I wish i saw this earlier. Could you set up a basic grouped UITableView?

    Thanks!

    Please Register or Log in to view images

  9. atomicmufin

    atomicmufin Banned

    Joined:
    Jun 5, 2008
    Messages:
    1,549
    Likes Received:
    1
    Device:
    iPhone 4 (Black)
  10. MrCrawley

    MrCrawley New Member

    Joined:
    Apr 5, 2008
    Messages:
    338
    Likes Received:
    1
    holly lord! thanks a lot mate!

Share This Page