当前位置: 首页 > news >正文

公司网站如何租用服务器按效果付费的网络推广方式

公司网站如何租用服务器,按效果付费的网络推广方式,上海专业做网站的,华企网站建设推广优化UIPickerView 使用场景和功能UIPickerView遵循代理协议和数据源协议创建对象,添加代理必须实现的代理方法非必要实现的方法demo用到的其他函数提示 效果展示 使用场景和功能 UIPickerView 最常见的用途是作为选项选择器,允许用户从多个选项中选择一个。…

UIPickerView

  • 使用场景和功能
  • UIPickerView
    • 遵循代理协议和数据源协议
    • 创建对象,添加代理
    • 必须实现的代理方法
    • 非必要实现的方法
    • demo用到的其他函数
    • 提示
  • 效果展示

使用场景和功能

UIPickerView 最常见的用途是作为选项选择器,允许用户从多个选项中选择一个。UIPickerView 可以用于以滚动的方式展示大量数据,并允许用户通过滚动选择感兴趣的数据。一种很常见的用法是把各个数据以滚动的形式组成一个组合数据,比如年-月-日的日历或者时钟,以及省级-市级-区的地域 ;
这一部分的学习是参考学长的,用到了学长的plist文件 ;

UIPickerView

这个控件是iOS中自带的控件,使用方法类似于UItableview,所以就从UItableveiw的使用来分析了,这里跟着别人做了一个省级-市级-区的地域的小demo

遵循代理协议和数据源协议

#import <UIKit/UIKit.h>@interface ViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>
@property (nonatomic, strong) UIPickerView* pickerview ;
@property (nonatomic, strong) NSMutableArray* provinceArray ;
@property (nonatomic, strong) NSArray* cityArray ;
@property (nonatomic, strong) NSArray* areaArray ;
@end

创建对象,添加代理

self.pickerview = [[UIPickerView alloc] initWithFrame:CGRectMake(50, 100, 300, 200)] ;//类似于tableview,需要设置代理和数据源self.pickerview.delegate = self ;self.pickerview.dataSource = self ;[self.view addSubview:self.pickerview] ;

必须实现的代理方法

//组数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {return 3;
}
//行数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {if (component == 0) {return [self.provinceArray count];} else if (component == 1) {return [self.cityArray count];} else {return [self.areaArray count] ;}
}

可以参考Uitableview的行和列,差不多的

非必要实现的方法

//展示的信息,可以是NSSTring,也可以是UIview
//- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
//    return @"chabuduo";
//}
//

//pickerview滑动函数

  • (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

简单常用的上面两个,还有很多其他的代理方法,可以参考UItableview;

UIPickerView 的代理方法用于处理用户的选择操作、自定义选项的外观以及其他与 UIPickerView 相关的事件。以下是一些常用的 UIPickerViewDelegate 和 UIPickerViewDataSource 协议中的代理方法:
UIPickerViewDelegate 协议中的代理方法:
pickerView(:didSelectRow:inComponent:):
当用户选择了 UIPickerView 中的某一行时调用该方法。你可以在该方法中获取选择的行和列索引,并根据需要进行相应的处理。
pickerView(
:viewForRow:forComponent:reusing:):
返回自定义 UIView 对象作为指定行和列的内容视图。你可以使用此方法自定义选项的外观,例如改变文本颜色、字体等。
pickerView(:rowHeightForComponent:):
返回指定列的行高。你可以使用此方法设置特定列的行高,以使选项在 UIPickerView 中正确显示。
UIPickerViewDataSource 协议中的代理方法:
numberOfComponents(in:):
返回 UIPickerView 中的列数(组件数)。你需要在此方法中指定需要显示的列数。
pickerView(
:numberOfRowsInComponent:):
返回指定列中的行数。你需要在此方法中指定每个列的行数,以确定每列将显示多少选项。

demo用到的其他函数

- (void)loadData {self.provinceArray = [[NSMutableArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"area.plist" ofType:nil]] ;self.cityArray = [[self.provinceArray objectAtIndex:0] objectForKey:@"cities"] ;self.areaArray = [[self.cityArray objectAtIndex:0] objectForKey:@"areas"] ;
}
- (UIView*)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {UILabel* myview = nil ;myview = [[UILabel alloc] init] ;myview.textAlignment = NSTextAlignmentCenter ;myview.font = [UIFont systemFontOfSize:22] ;if (component == 0) {myview.text = [[self.provinceArray objectAtIndex:row] objectForKey:@"state"] ;} else if (component == 1) {myview.text = [[self.cityArray objectAtIndex:row] objectForKey:@"city"] ;} else {myview.text = [self.areaArray objectAtIndex:row] ;}return myview ;
}
//pickerview滑动函数
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {if (component == 0) {self.cityArray = [[self.provinceArray objectAtIndex:row] objectForKey:@"cities"] ;[self.pickerview reloadComponent:1] ;//调整各组所选的对象[self.pickerview selectRow:0 inComponent:1 animated:YES] ;if ([self.cityArray count] != 0) {self.areaArray = [[self.cityArray objectAtIndex:0] objectForKey:@"areas"] ;[self.pickerview reloadComponent:2] ;[self.pickerview selectRow:0 inComponent:2 animated:YES] ;}} else if (component == 1) {if ([self.cityArray count] != 0) {self.areaArray = [[self.cityArray objectAtIndex:row] objectForKey:@"areas"] ;[self.pickerview reloadComponent:2] ;[self.pickerview selectRow:0 inComponent:2 animated:YES] ;}} else {}
}

提示

其他没啥好说的了,因为用起来真的太像UItableview了,这里简单解释一下滑动函数的逻辑,如果滑动“省”,则更新市和区的component并其row归零;如果滑动“市”,则更新区的component并归零 ;

效果展示

在这里插入图片描述

http://www.zhongyajixie.com/news/62899.html

相关文章:

  • 个人制作网站工具广州推广工具
  • 中国新兴建设招聘网站谷歌应用商店app下载
  • 餐饮品牌网站建设百度推广的几种方式
  • 用来做视频连接的网站郑州疫情最新消息
  • 网站维护 收录推广文案怎么写吸引人
  • 免费无广告建站百度有钱花人工客服
  • 常用搜索网站如何申请域名
  • 杭州建站模板展示国外网站seo
  • 网页制作流程分为哪几个步骤搜索引擎优化趋势
  • 重庆忠县网站建设公司哪家好怎么开网店
  • 呼和浩特网站建设宣传登封搜索引擎优化
  • 做网站和推广seo在线培训机构
  • 西安到北京飞机几个小时网站内容优化关键词布局
  • 开发 网站 费用seo竞价推广
  • 长沙网站建设建关键词优化公司哪家强
  • 网站域名指什么优化设计六年级下册语文答案
  • 北京 网站空间 租用短视频推广渠道有哪些
  • 假山网站如何做怎么在百度上做广告推广
  • 怎么做网上问卷湖南seo推广系统
  • 通辽做家教的网站电商网络销售是做什么
  • 如何做自己的公司网站网络运营培训班
  • 中小企业网站多大空间互联网推广怎么找客户
  • 公司简介模板免费图片泉州百度seo公司
  • pc网站 公众号数据互通千锋教育培训
  • 建设公司营销网站百度seo排名优化排行
  • 罗湖附近公司做网站建设哪家技术好永久免费域名注册
  • 济南网站制作软件中国seo高手排行榜
  • 苏州建筑设计公司seo外包是什么意思
  • 外贸网站制作价格表苏州网站建设公司排名
  • 百度网站提交入口百度seo技术软件