zoukankan      html  css  js  c++  java
  • UIpickerView




    #import
    "DengViewController.h" @interface DengViewController () @end @implementation DengViewController - (void)viewDidLoad { [super viewDidLoad]; CGRect rect=CGRectMake(0, 0,320, 220); _showlabel=[[UILabel alloc] initWithFrame:rect]; _showlabel.backgroundColor=[UIColor grayColor]; _showlabel.textAlignment=NSTextAlignmentCenter; _showlabel.font=[UIFont systemFontOfSize:18]; [self.view addSubview:_showlabel]; UIPickerView *pickerview = [[UIPickerView alloc] init]; CGRect fram =pickerview.frame; fram.origin.y=self.view.bounds.size.height-fram.size.height; pickerview.frame=fram; pickerview.showsSelectionIndicator=YES; pickerview.backgroundColor=[UIColor yellowColor]; pickerview.delegate=self; pickerview.dataSource=self; [self.view addSubview:pickerview]; [pickerview reloadAllComponents]; [self pickerView:pickerview didSelectRow:0 inComponent:0]; // Do any additional setup after loading the view, typically from a nib. } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 2; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ return 9; } - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{ return 30; } - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{ return 80; } - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ if (view==nil) { CGFloat width = [self pickerView:pickerView widthForComponent:component]; CGFloat heigh = [self pickerView:pickerView rowHeightForComponent:row]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, heigh)]; label.textAlignment=NSTextAlignmentCenter; label.font=[UIFont systemFontOfSize:16]; view=label; } UILabel *label =(UILabel*)view; label.text=[NSString stringWithFormat:@"%d",row+1]; if (row%2!=1) { label.backgroundColor=[UIColor redColor]; } return label; } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ NSInteger row0 =[pickerView selectedRowInComponent:0]; NSInteger row1 =[pickerView selectedRowInComponent:1]; UILabel *label1=(UILabel *)[pickerView viewForRow:row0 forComponent:0]; UILabel *label2=(UILabel *)[pickerView viewForRow:row1 forComponent:1]; int result =label1.text.intValue*label2.text.intValue; _showlabel.text=[NSString stringWithFormat:@"%d",result]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
  • 相关阅读:
    Java 签名(SHA1WithRSA、SHA256WithRSA、SHA256withECDSA)
    记一次用WireShark抓包摆脱Si服后台限制的过程
    反向代理Nginx
    对于新能源Can数据、电池BMS等字节和比特位的解析
    WireShark抓包命令
    .NET下寄宿于控制台的HTTPS监听
    RSA等非对称加密为什么要用公钥加密,而用私钥解密?
    FTP、SFTP与FTPS
    Python打包方法——Pyinstaller
    [Python爬虫]煎蛋网OOXX妹子图爬虫(1)——解密图片地址
  • 原文地址:https://www.cnblogs.com/deng37s/p/4583475.html
Copyright © 2011-2022 走看看