- 浏览: 2481617 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
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
UIAlertTableView.h
#import <UIKit/UIKit.h> @class UIAlertView; @interface UIAlertTableView : UIAlertView { UIAlertView *alertView; UITableView *tableView; int tableHeight; int tableExtHeight; id <UITableViewDataSource> dataSource; id <UITableViewDelegate> tableDelegate; } @property (nonatomic, assign) id dataSource; @property (nonatomic, assign) id tableDelegate; @property (nonatomic, readonly) UITableView *tableView; @property (nonatomic, assign) int tableHeight; - (void)prepare; @end
UIAlertTableView.m
#import "UIAlertTableView.h" #define kTablePadding 8.0f @interface UIAlertView (private) - (void)layoutAnimated:(BOOL)fp; @end @implementation UIAlertTableView @synthesize dataSource; @synthesize tableDelegate; @synthesize tableHeight; @synthesize tableView; - (void)layoutAnimated:(BOOL)fp { [super layoutAnimated:fp]; [self setFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y - tableExtHeight / 2, self.frame.size.width, self.frame.size.height + tableExtHeight)]; UIView *lowestView; int i = 0; while (![[self.subviews objectAtIndex:i] isKindOfClass:[UIControl class]]) { lowestView = [self.subviews objectAtIndex:i]; i++; } CGFloat tableWidth = 262.0f; tableView.frame = CGRectMake(11.0f, lowestView.frame.origin.y + lowestView.frame.size.height + 2 * kTablePadding, tableWidth, tableHeight); for (UIView *v in self.subviews) { if ([v isKindOfClass:[UIControl class]]) { v.frame = CGRectMake(v.frame.origin.x, v.frame.origin.y + tableExtHeight, v.frame.size.width, v.frame.size.height); } } } - (void)show{ [self prepare]; [super show]; } - (void)prepare { if (tableHeight == 0) { tableHeight = 150.0f; } tableExtHeight = tableHeight + 2 * kTablePadding; tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f) style:UITableViewStylePlain]; tableView.backgroundColor = [UIColor orangeColor]; tableView.delegate = tableDelegate; tableView.dataSource = dataSource; [self insertSubview:tableView atIndex:0]; [self setNeedsLayout]; } - (void)dealloc { [tableView release]; [super dealloc]; } @end
AlertTableViewController.h
#import <UIKit/UIKit.h> @interface AlertTableViewController : UIViewController <UIAlertViewDelegate, UITableViewDelegate, UITableViewDataSource> { UITableView *myTableView; NSArray *array; NSIndexPath *lastIndexPath; } @property (nonatomic, retain) NSIndexPath *lastIndexPath; - (IBAction)btnClick:sender; @end
AlertTableViewController.m
#import "AlertTableViewController.h" #import "UIAlertTableView.h" @implementation AlertTableViewController @synthesize lastIndexPath; - (void)viewDidLoad { array = [[NSArray alloc] initWithObjects:@"test1", @"test2", @"test3", @"test4", nil]; [super viewDidLoad]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [array count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } NSUInteger row = [indexPath row]; NSUInteger oldRow = [lastIndexPath row]; cell.textLabel.text = [array objectAtIndex:row]; cell.accessoryType = (row == oldRow && lastIndexPath != nil) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; return cell; } - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{ return indexPath; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 40; } - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int newRow = [indexPath row]; int oldRow = [lastIndexPath row]; if ((newRow == 0 && oldRow == 0) || (newRow != oldRow)){ UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath]; newCell.accessoryType = UITableViewCellAccessoryCheckmark; UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: lastIndexPath]; oldCell.accessoryType = UITableViewCellAccessoryNone; lastIndexPath = [indexPath retain]; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (IBAction)btnClick:sender { UIAlertTableView *alert = [[UIAlertTableView alloc] initWithTitle:@"Select Option" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Do", nil]; alert.tableDelegate = self; alert.dataSource = self; alert.tableHeight = 120; [alert show]; [alert release]; } - (void)dealloc { [lastIndexPath release]; [array release]; [super dealloc]; } @end
示例图:
发表评论
-
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,支持背景和按钮的自定义
刚开始的做法 是 UIAlertView 的基础上addsubview上UITableView,UITableView的大小固定,但是 出现 横屏的时候 UITableView跟UIAlertView的大小不搭配了 ,后来自定义一个UIAlertView的继承类,重写了 ...
自定义Alertview的Demo,给想要学习自定义的同学提供一些思路。建议看看我的博客,有这个demo的详细讲解blog.csdn.net/hello_hwc
https://github.com/STShenZhaoliang/STAlertView 感谢大家给提bug
这个程序是在iPhone3.1.3的模拟器测试通过的,如果大家需要定制UIAlertView的Table请下载这个程序,有很好的参考价值
作者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。