- 浏览: 2481625 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
jsntghf:
peio 写道这个怎么运行?Ruby On Rails的环境搭 ...
多文件上传之uploadify -
peio:
这个怎么运行?
多文件上传之uploadify -
往事如烟1:
我的项目是自己init了一个原始的project,之后将ver ...
React Native热部署之CodePush -
jsntghf:
往事如烟1 写道我按照你的说明进行,发现app退出之后,在进入 ...
React Native热部署之CodePush -
往事如烟1:
我按照你的说明进行,发现app退出之后,在进入不正确,请问是什 ...
React Native热部署之CodePush
头文件:
#import <UIKit/UIKit.h> @interface CustomPickerView : UIAlertView <UIPickerViewDataSource, UIPickerViewDelegate> { NSArray *majorNames; NSArray *grades; UIPickerView *selectPicker; int selectedMajor; int selectedGrade; } @end
实现文件:
#import "CustomPickerView.h" #define componentCount 2 #define majorComponent 0 #define gradeComponent 1 #define majorComponentWidth 165 #define gradeComponentWidth 70 @implementation CustomPickerView - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { majorNames = [[NSArray alloc]initWithObjects:@"111", @"222", @"333", @"444", @"555", nil]; grades = [[NSArray alloc]initWithObjects:@"aaa", @"bbb", @"ccc", @"ddd", @"eee", nil]; selectPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)]; selectPicker.showsSelectionIndicator = YES; selectPicker.delegate = self; selectPicker.dataSource = self; selectPicker.opaque = YES; [self addSubview:selectPicker]; } return self; } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return componentCount; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { if (component == majorComponent) { return [majorNames count]; } else { return [grades count]; } } - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *printString; if (component == majorComponent) { printString = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, majorComponentWidth, 45)]; printString.text = [majorNames objectAtIndex:row]; [printString setFont:[UIFont fontWithName:@"Georgia" size:12.0f]]; } else { printString = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, gradeComponentWidth, 45)]; printString.text = [grades objectAtIndex:row]; } [printString autorelease]; printString.backgroundColor = [UIColor clearColor]; printString.textAlignment = UITextAlignmentCenter; return printString; } - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { return 45.0; } - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { if (component == majorComponent) { return majorComponentWidth; } else { return gradeComponentWidth; } } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { selectedMajor = [pickerView selectedRowInComponent:majorComponent]; selectedGrade = [pickerView selectedRowInComponent:gradeComponent]; } - (void)setFrame:(CGRect)rect { [super setFrame:CGRectMake(0, 0, rect.size.width, 330)]; self.center = CGPointMake(320/2, 480/2); } - (void)layoutSubviews { selectPicker.frame = CGRectMake(10, 45, self.frame.size.width - 52, self.frame.size.height - 50); for (UIView *view in self.subviews) { if ([[[view class] description] isEqualToString:@"UIThreePartButton"]) { view.frame = CGRectMake(view.frame.origin.x, self.bounds.size.height - view.frame.size.height - 15, view.frame.size.width, view.frame.size.height); } } } - (void)dealloc { [super dealloc]; } @end
示例:
CustomPickerView *alert = [[CustomPickerView alloc] initWithTitle:@"Orange" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Submit", nil]; [alert show]; [alert release];
示例图:
发表评论
-
Error watching file for changes: EMFILE
2016-12-15 11:57 1247执行npm start后报错: Error watc ... -
CocoaPods升级1.1.1报错
2016-12-15 08:39 748ERROR: While executing gem .. ... -
Visual Studio Code运行React Native报错
2016-06-13 09:43 1571React Native:0.27.2 React:15 ... -
React Native 0.27.2编译报错this._nativeModule.addListener is not a function
2016-06-12 15:21 3805React Native:0.27.2 React:15 ... -
Unable to resolve module ReactDefaultPerf from
2016-06-02 13:04 2740package.json信息如下: "reac ... -
React Native 0.26.2编译报错Undefined symbols for architecture x86_64
2016-05-26 11:15 1954React Native:0.26.2 React:15. ... -
Failed to update auto layout status: Failed to load designables from path (null)
2016-04-05 22:11 1675确保CocoaPods是0.36.1以上版本,然后在podf ... -
集成微信支付出现Undefined symbols for architecture x86_64错误
2016-03-21 13:22 1696Undefined symbols for architec ... -
React Native热部署之CodePush
2016-01-10 22:27 6143本文使用的环境是Mac OS 10.11.1、Xcode ... -
浅谈React Native中的FlexBox布局
2015-11-17 18:38 4277React Native通过一个基于FlexBox的布局引 ... -
React Native之构建一个简单的列表页
2015-10-23 14:45 2103本文中我们将创建一个简单的电影应用,这个应用将从Rotten ... -
React Native之环境搭建
2015-10-20 16:30 1399本文使用的环境是Mac O ... -
获取图片属性的方法
2015-10-18 20:43 3092很多时候我们需要获 ... -
NSCache的下标用法
2015-09-18 00:19 1175NSCache类和NSDictionary类很相似,也提供 ... -
如何给category添加属性
2015-08-16 10:41 647主要是使用了runtime中的associative机制。 ... -
UITableView的两种重用Cell方法的区别
2015-08-10 13:07 16073UITableView中有两种重用Cell的方法: - ... -
SDImageCache.m报错Unused variable 'fileName'
2015-08-04 21:56 1142GCC手册中的相关解释: unused:This att ... -
Swift调用Objective-C
2015-07-13 23:33 1188Swift调用Objective-C需要一个名为<工程 ... -
使用GCD实现倒计时
2015-07-24 21:47 1051__block int timeout = 60; // ... -
导航栏加分割线的实现
2015-07-01 22:00 1702self.view.backgroundColor = [U ...
相关推荐
自定义 UIAlertView
https://github.com/STShenZhaoliang/STAlertView 400行写的自定义UIAlertView,没有开太多接口,大家可以自由修改。
1.系统的UIAlertView使用方便,但是有时需要三个按钮,这时的UIAlertView会出现问题,三个按钮的默认摆放位置,不尽人意 2.使用UIAlertView的Delegate,来修改其布局
ios7 自定义UIAlertView ios7 UIAlertView 弹出 警告 自定义 简单实用。 支持转屏
自定义UIAlertView,直接继承UIView,支持背景和按钮的自定义
自定义Alertview的Demo,给想要学习自定义的同学提供一些思路。建议看看我的博客,有这个demo的详细讲解blog.csdn.net/hello_hwc
https://github.com/STShenZhaoliang/STAlertView 感谢大家给提bug
作者paozi-jun,源码YYAlertView,Swift 语言编写自定义控件, 实现一个自定义的UIAlertView 。
自定义警告框、弹出框AlertView 自定义AlertView 实现自定义UIAlertView。继承UIAlertView,改写其中的layoutSubviews方法,用于自定义UIAlertView的外观
自定义iOS AlertView v0.9.5 support for iOS7+ 自iOS7开始,addAlview在UIAlertView中不可用。 此类的视图层次结构是私有的,不能修改。 作为解决方案,此类创建一个iOS样式的对话框,您可以使用任何UIViews或...
源码实现了怎样自定义UIAlertView的样式,包括背景图片以及按钮图片等等。是一个不错的学习例子,希望能够帮助到大家,。
ios自定义UIAlertView,继承的UIAlertView,而不是UIView.
自定义类似于UIAlertView
iOS 自定义UIAlertView ,使用第三方库Custom iOS7 AlertView,点击右上角itembar 弹出AlertView。
刚开始的做法 是 UIAlertView 的基础上addsubview上UITableView,UITableView的大小固定,但是 出现 横屏的时候 UITableView跟UIAlertView的大小不搭配了 ,后来自定义一个UIAlertView的继承类,重写了 ...
自定义UIAlertView,消息文字可以左对齐,居中,右对齐。显示时具有动画效果
源码实现如何自定义UIAlertView。继承UIAlertView,并改写其中的layoutSubviews方法,喜欢的朋友可以下载用于自定义UIAlertView的外观。是一个很好的例子,。