IOS 小知识总结

为UIImageView添加单击事件:
-------初始化一个Image-------
imageView.userInteractionEnabled = YES;


UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourHandlingCode:)];


[imageView addGestureRecognizer:singleTap];




,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>{


-------属于某一个类--------
 if([view isKindOfClass:[UITabBar class]]) 


-------初始化BUtton--------
loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
[loginButton setFrame:CGRectMake(470, 485, 119, 59)];
[loginButton setBackgroundImage:[UIImage imageNamed:@"login_button.png"] forState:UIControlStateNormal];
[loginButton addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];


-------初始化一个Image-------


passwordLabel = [[UIImageView alloc] initWithFrame:CGRectMake( 332, 420, 60, 60)];
passwordLabel.image = [UIImage imageNamed:@"Key.png"];
[self.view addSubview:passwordLabel];

passwordField = [[UITextField alloc] initWithFrame:CGRectMake( 415, 440, 220, 21)];
passwordField.autocorrectionType = UITextAutocorrectionTypeNo;
passwordField.clearButtonMode = UITextFieldViewModeWhileEditing;
passwordField.clearsOnBeginEditing = NO;

passwordField.font = [UIFont systemFontOfSize:20];
passwordField.secureTextEntry = YES;
passwordField.placeholder = @"Password";
passwordField.delegate = self;
[self.view addSubview:passwordField];


------------------UIImageView--------------------
imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(398, 350, 275, 58)];
imageView1.image = [UIImage imageNamed:@"login_cell.png"];






------------------UIAlertView---------------------


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"是否确定切换用户?" 
message:@"切换用户会清空当前登录用户的任务观察记录"
  delegate:self 
 cancelButtonTitle:@"取消" otherButtonTitles:@"切换",nil];
 *alert = [[UIAlertView alloc] initWithTitle:@"是否确定切换用户?" 
message:@"切换用户会清空当前登录用户的任务观察记录"
  delegate:self 
 cancelButtonTitle:@"取消" otherButtonTitles:@"切换",nil];


----------------------thread------------------------
NSThread *thread=[[NSThread alloc]initWithTarget:self selector:@selector(run) object:nil];
[thread setName:@"GO"];
[thread start];


[self performSelectorOnMainThread:@selector(finished) withObject:nil waitUntilDone:YES];




----------------------main------------------------
MainViewController *mainView = [[MainViewController alloc] init];
[[(TaskObserveAppDelegate *)[[UIApplication sharedApplication] delegate] window] addSubview:mainView.view];
[self.view removeFromSuperview];
self.view = nil;




----------------------button------------------------
UIButton *taskButton = [UIButton buttonWithType:UIButtonTypeCustom];
[taskButton setFrame:CGRectMake(340, 650, 90, 90)];
[taskButton setBackgroundImage:[UIImage imageNamed:@"task_bg_.png"] forState:UIControlStateNormal];
[taskButton addTarget:self action:@selector(taskButtonPressed:) forControlEvents:UIControlEventTouchUpInside];


---------------UITableView------------
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 748)];
UIImageView *taskimage = [[UIImageView alloc] initWithFrame:CGRectMake(0, -30, 1024, 748)];
taskimage.image = [UIImage imageNamed:@"task_table_image.png"];
[view1 addSubview:taskimage];

listView = [[UITableView alloc] initWithFrame:CGRectMake(59, 105, 900, 426) style:UITableViewStylePlain];
listView.delegate = self;
listView.dataSource = self;
listView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[listView setBackgroundColor:[UIColor clearColor]];

[self getlistArray];
[view1 addSubview:listView];
[scrollView addSubview:view1];


----------- cell------------------------
WorkListCell *cell = (WorkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"WorkListCell" owner:self options:nil] lastObject];
cell.idLabel.text = [[listArray objectAtIndex:indexPath.row] observe_number];
[cell.idLabel setTextColor:WORD_COLOR];




-----------转圈---------------------
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
[indicator startAnimating];
[alert addSubview:indicator];
[indicator release];




----------------requst--------------------------


if (stdDown && stdDown.downUrl) {
ASIHTTPRequest *request2 = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:stdDown.downUrl]];
[request2 setTimeOutSeconds:600];
[request2 setDelegate:self];
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *dbPath = [documentPath stringByAppendingPathComponent:@"TASKVIEWSTD.DB"];
[request2 setDownloadDestinationPath:dbPath];
[request2 startAsynchronous];




--------------requestFailed-------------------
- (void)requestFailed:(ASIHTTPRequest *)request{
NSError *error = [request error];
[alert dismissWithClickedButtonIndex:0 animated:YES];
if ([error localizedDescription]) {
alert = [[UIAlertView alloc] initWithTitle:@"下载标准库错误:" 
  message:[error localizedDescription]
 
 delegate:self 
cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
}
}




-------------------color-------------------
[cell.timeLabel setTextColor:WORD_COLOR];


#define WORD_COLOR UIColorFromRGB(0x50729f)
#define ROATE NO


-----------转换----------------------
[ActionViewController setObserveInfo:(ObserveInfo *)[listArray objectAtIndex:indexPath.row]];




12、页面切换效果设置:


controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;


[self presentModalViewController:controller animated:YES];


可供使用的效果:


UIModalTransitionStyleCoverVertical


UIModalTransitionStyleFlipHorizontal


UIModalTransitionStyleCrossDissolve


UIModalTransitionStylePartialCurl


恢复之前的页面:


[self dismissModalViewControllerAnimated:YES];




4、设置和获取类中属性值:


[self setValue: 变量值 forKey: 变量名];


[self valueForKey: 变量名];


5、让某一方法在未来某段时间之后执行:


[self performSelector:@selector(方法名) withObject:nil afterDelay:延迟时间(s)]; 


6、获得设备版本号:


float version = [[[UIDevice currentDevice] systemVersion] floatValue];


7、捕捉程序关闭或者进入后台事件:


UIApplication *app = [UIApplication sharedApplication];


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:app];


applicationWillResignActive:这个方法中添加想要的操作


小知识点:
http://www.cocoachina.com/newbie/tutorial/2012/1016/4928.html
weixin063传染病防控宣传微信小程序系统的设计与实现+springboot后端毕业源码案例设计 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值