About
Home > Tutorials Home > Ios > UIPickerview Partition in iOS

UIPickerview Partition in iOS

Published on November 30, -0001 12:00:00 AM

alert-view

We are an online tutoring company that has laid its foundation in utilizing Multiple Intelligence methodology to understand specific needs and learning styles of a student.IOS UIPickerView-like control in WPF,WPF may refer to WebSphere Partition Facility, an IBM facility Western People's , a UIPickerView (the "tumblers" UI common on the iPhone) control in WPF.So that we patch a particular student to a tutor having a compatible teaching style. We have devised a smart online tutoring system to give you measurable results.Schools, cramped with students, fail to give your child the edge, the motivation and the right teacher guidance to help him find the true potential. We at Eonlinetutors.com make sure that your child gets the perfect learning environment to outperform.




Step 1 : Open the XCode and create a new Single View Based Application template. Give the application name "Multiple Button in AlertView Example". Copy this Code to the ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIPickerViewDataSource,UIPickerViewDelegate>

@property (weak, nonatomic) IBOutlet UIPickerView *pickerControl;
@property (weak, nonatomic) IBOutlet UILabel *lblMessage;
@property (nonatomic,retain) NSArray *countries;
@property(nonatomic,retain) NSArray *states;

@end


Step 2 : Copy the Following Code into your ViewController.m File.

#import "ViewController.h"

@implementation ViewController

@synthesize pickerControl;
@synthesize lblMessage;
@synthesize countries, states;

- (void)viewDidLoad
{
    countries = [[NSArray alloc]initWithObjects:@"India",@"UK",@"England",@"Australia",@"Canada", @"NewYork",@"America",@"SriLanka", nil];
	states = [[NSArray alloc]initWithObjects:@"Gujarat",@"UK State",@"Loards",@"Melboarn",@"Canada State",@"NewYork  State",@"WashingTon",@"Kolambo", nil];
	[super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if(component == 0)
    {
        return [countries objectAtIndex:row];
    }
    else
    {
        return  [states objectAtIndex:row];
	}
}

// returns the number of 'columns' to display.

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}

// returns the # of rows in each component..

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if(component == 0)
	{
        return [countries count];
	}
    else
    {
        return [states count];
	}
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    NSString *fullname = [NSString stringWithFormat:@"%@, %@",[countries objectAtIndex:row],[states objectAtIndex:row]];
	[lblMessage setText:fullname];
}

@end

ALL COMMENTS (2)
Abhishek Bedre 2017-03-28 17:25:15
I have implemented my own "jarvis"....thanks to this example.        
2019-01-03 13:22:19
It is working fine in desktop but not working in android mobile