13年iOS笔记小结

#pragma mark –内容

(标记方法的方法)

       UIAlertView * Alert =[[UIAlertView alloc]initWithTitle:@"提示"message:@"请输入用户名和密码" delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"确定", nil];

       [Alert show];

 

 

字符串

   if ([UserNumber.textisEqualToString:@"lebo"]&&[UserPassword.textisEqualToString:@"123456"] ) {

   

       NSLog(@"成功");

   

       }

 

 

返回按

-(void)addViewAction

{

   UIButton * BackBtn =[UIButton buttonWithType:UIButtonTypeCustom];

   BackBtn.frame =CGRectMake(0,5,55, 30);

   [BackBtn setImage:[UIImage imageNamed:@"返回(1).png"] forState:UIControlStateNormal];

   [BackBtn setImage:[UIImage imageNamed:@"返回(2).png"] forState:UIControlStateHighlighted];

   [BackBtn addTarget:self action:@selector(BackBtnAction)forControlEvents:UIControlEventTouchUpInside];

   self.navigationItem.leftBarButtonItem =[[UIBarButtonItemalloc]initWithCustomView:BackBtn];

   

}

- (void)viewDidLoad

{

   [super viewDidLoad];

 

   [self addViewAction];

 

 

 

//UITextField输入内容,点击空白处收起键盘的方法

- (void)touchesBegan:(NSSet *)toucheswithEvent:(UIEvent *)event

{

 // 前面是textfield名

   [UserNumber resignFirstResponder];

   [UserPassword resignFirstResponder];

}

 

 

增加监听,当键盘出现或改变时调用的方法

   

   [[NSNotificationCenter defaultCenter] addObserver:self

                           selector:@selector(keyboardWillShow:)

                           name:UIKeyboardWillShowNotification

                            object:nil];

   

增加监听,当键盘退出时调用的方法

    [[NSNotificationCenter defaultCenter]addObserver:self

    selector:@selector(keyboardWillHide:)

    name:UIKeyboardWillHideNotification

    object:nil];

 

 

 键盘或改变时调用的具体方法

- (void)keyboardWillShow:(NSNotification*)aNotification

 

{

    键盘高度

   NSDictionary *userInfo = [aNotification userInfo];

   NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

   CGRect keyboardRect = [aValue CGRectValue];

   CGFloat height = keyboardRect.size.height;

   CGSize size =self.view.frame.size;

   

   [UIView animateWithDuration:0.5 animations:^{

       self.view.frame =CGRectMake(0, -height,size.width, size.height);

   }];

}

键盘退出时调用的具体方法

- (void)keyboardWillHide:(NSNotification*)aNotification

{

   CGSize size =self.view.frame.size;

   [UIView animateWithDuration:0.5 animations:^{

       self.view.frame =CGRectMake(0,0,size.width, size.height);

 

   }];

   

}

尔键值池

       [[NSUserDefaults standardUserDefaults] setBool:NOforKey:@"Pltitle"];

 

 

取字体的                  

   NSString  * Str =[PicNameArrayobjectAtIndex:indexPath.row];

   CGSize size = [Str sizeWithFont:[UIFont systemFontOfSize:18]constrainedToSize:CGSizeMake(276.0f, 300.0f)lineBreakMode:UILineBreakModeWordWrap];

 

 

viewWillAppear:

Called when the view is about to madevisible. Default does nothing

视图即将可见时调用。默认情况下不执行任何操作

viewDidAppear:

Called when the view has been fullytransitioned onto the screen. Default does nothing

视图已完全过渡到屏幕上时调用

viewWillDisappear:

Called when the view is dismissed, coveredor otherwise hidden. Default does nothing

视图被驳回时调用,覆盖或以其他方式隐藏。默认情况下不执行任何操作

viewDidDisappear:

Called after the view was dismissed,covered or otherwise hidden. Default does nothing

视图被驳回后调用,覆盖或以其他方式隐藏。默认情况下不执行任何操作

 

loadView;

This is where subclasses should createtheir custom view hierarchy if they aren't using a nib. Should never be calleddirectly.

这是当他们没有正在使用nib视图页面,子类将会创建自己的自定义视图层。绝不能直接调用。

viewDidLoad;

Called after the view has been loaded. Forview controllers created in code, this is after -loadView. For view controllersunarchived from a nib, this is after the view is set.

在视图加载后被调用,如果是在代码中创建的视图加载器,他将会在loadView方法后被调用,如果是从nib视图页面输出,他将会在视图设置好后后被调用。

 

 

义图片名字为变量的方法

       for (int i=0; i<3; i++)

    {

       NSString * ImageName =[[NSStringalloc]initWithFormat:@"sharepic%d",i+1];

       UIImageView * LogoImage =[[UIImageView alloc]initWithImage:[UIImageimageNamed:ImageName]];

 }

电话

- (IBAction)IBActionThree:(id)sender {

   [[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"tel://10086"]];

 

}

 

 

 

 

访问

- (IBAction)IBActionOne:(id)sender {

 [[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"http://www.wlantv.cn"]]

    ;

 

}

 

APPstore打分

- (IBAction)IBActionTwo:(id)sender {

   NSString *str = [NSString stringWithFormat:

                    @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",

                     m_appleID ];

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

 

}

 

tableview grouped 模式的相关

//

-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView

{

   return 2;

}

 

-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section

{  

   if (section==0) {

       return [picArray count];

    }

   else{

       return [pic2Array count];

    }

}

 

 

// cell中添加内容

 

-(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

   NSString *CellIdentifier = [NSStringstringWithFormat:@"Cell"];

 

   UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:CellIdentifier];

   

   if (cell == nil) {

       cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    }

   for (UIImageView * Image1view in cell.contentView.subviews) {

       [Image1view removeFromSuperview];

    }

   for (UILabel * Label in cell.contentView.subviews) {

       [Label removeFromSuperview];

    }

   if (indexPath.section==0) {

       UIImageView * Image1View =[[UIImageViewalloc]initWithFrame:CGRectMake(10, 7, 25, 25)];

       Image1View.image = [picArray objectAtIndex:indexPath.row];

       [cell.contentView addSubview:Image1View];

       

       UILabel * Label =[[UILabel alloc]initWithFrame:CGRectMake(50, 0, 100,35)];

       Label.backgroundColor=[UIColor clearColor];

       Label.userInteractionEnabled=YES;

        Label.text =[PicNameArrayobjectAtIndex:indexPath.row];

       Label.textColor =[UIColor whiteColor];

       Label.textAlignment =UITextAlignmentLeft;

       cell.selectionStyle = UITableViewCellSelectionStyleNone;

 

       [cell.contentView addSubview:Label];

        //添加

       UIImageView * ImageView =[[UIImageViewalloc]initWithFrame:CGRectMake(275, 5, 30, 30)];

       ImageView.image = [ArrowArray objectAtIndex:indexPath.row];

       [cell.contentView addSubview:ImageView];

       

    }

   else{

       UIImageView * Image3View =[[UIImageViewalloc]initWithFrame:CGRectMake(10, 7, 25, 25)];

       Image3View.image = [pic2Array objectAtIndex:indexPath.row];

       [cell.contentView addSubview:Image3View];

       

       UILabel * Label =[[UILabel alloc]initWithFrame:CGRectMake(50, 0, 100,35)];

       Label.backgroundColor=[UIColor clearColor];

       Label.userInteractionEnabled=YES;

       Label.text =[PicName2Array objectAtIndex:indexPath.row];

       Label.textColor =[UIColor whiteColor];

       Label.textAlignment =UITextAlignmentLeft;

       cell.selectionStyle = UITableViewCellSelectionStyleNone;

 

       [cell.contentView addSubview:Label];

       

       //添加红箭头

       UIImageView * Image1View =[[UIImageView alloc]initWithFrame:CGRectMake(275,5, 30, 30)];

       Image1View.image = [Arrow2Array objectAtIndex:indexPath.row];

       [cell.contentView addSubview:Image1View];

    }

       cell.textLabel.textAlignment =UITextAlignmentLeft;

   

   cell.backgroundColor =[[UIColor alloc]initWithRed:0.28235294green:0.28235294 blue:0.28235294 alpha:1];

   

   cell.textLabel.textColor=[UIColor whiteColor];

   

//   cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

   

   return cell;

}

 

// cell高度

-(float)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath

{

   return 40;

}

// 块标题

-(NSString *)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section

{  if (section==0) {

   return @"我的乐播";

}

else{

   return @"其他";

}

 

}

// 自定义标题样

-(UIView *)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section

{

   UIView * Viee =[[UIView alloc]init];

   Viee.backgroundColor=[UIColor clearColor];

   UILabel *Vieee =[[UILabel alloc]init];

   Vieee.backgroundColor=[UIColor clearColor];

   Vieee.textColor = [UIColor whiteColor];  

if (section==0) {

   Vieee.text=@"    我的乐播";

   }

   else{

 Vieee.text=@"    其他";

    }

   return Vieee;

   return Viee;

   

}

 

tableView 区域定义      

   [DiscussTableView scrollRectToVisible:CGRectMake(0,height-Frame.size.height, 320, Frame.size.height) animated:YES];

 

 

 

// for中的 imageview的方法

           UIImageView * ImageViewL =(UIImageView *)[ScreenView viewWithTag:400];

                ImageViewL.hidden=YES;

 

//手写button添加事件方法

   [ScreenBtn addTarget:self action:@selector(ScreenBtn:)forControlEvents:UIControlEventTouchUpInside];

 

//小按方法内容 ********

-(void)littleBtn:(id)sender

{

// for中的Button方法

   UIButton * Btn =(UIButton *)sender;

   UIScrollView * ScrollView =(UIScrollView *)[ScreenView viewWithTag:300];

   for (UIButton *button in ScrollView.subviews) {

       if (button.tag >=100 && button.tag<106) {

           [button setBackgroundImage:nil forState:UIControlStateNormal];

           [button setTitleColor:[UIColor grayColor]forState:UIControlStateNormal];

 

       }

    }

   [Btn setBackgroundImage:[UIImage imageNamed:@"3-点播-本地专区_12.png"] forState:UIControlStateNormal];

   [Btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

}

 

  //scrollview距离

 

classScrollView.contentSize=CGSizeMake((classBtn.frame.size.width+20)*number,classScrollView.frame.size.height);

 

// 视频列表scroll 代理方法  ******开始滑

 

-(void)scrollViewWillBeginDragging:(UIScrollView*)scrollView

 

 

// 视频列表scroll 代理方法 ******  监测scrollview    

-(void) scrollViewDidScroll:(UIScrollView*) scrollView{

//  根据x标判断

  if(scrollView.contentOffset.x==0) {

// 去除ScrollView滚动

 

    

  classScrollView.showsHorizontalScrollIndicator = FALSE;

 

NSLOG格式

 

 

 

//

self.navigationController.navigationBar.hidden=NO;

//

   [[UIApplication sharedApplication] setStatusBarHidden:NO];

 

 

NSArray *fontArray = [UIFontfamilyNames];

   NSLog(@"%@",fontArray);

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值