多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > iOS 一些常用的筆記

iOS 一些常用的筆記

來源:程序員人生   發布時間:2015-04-08 08:05:32 閱讀次數:2561次

iOS開發筆記(1)


退回輸入鍵盤:

  1.  - (BOOL) textFieldShouldReturn:(id)textField{  
  2.     [textField  resignFirstResponder];  
  3. }   

CGRect

CGPoint & CGSize

  1. CGPoint aPoint = CGPointMake(x, y);    CGSize aSize = CGSizeMake(width, height);   

設置透明度

  1. [myView setAlpha:value];   (0.0 < value < 1.0)   

設置背風景

  1. [myView setBackgroundColor:[UIColor redColor]];  
  2.    (blackColor;darkGrayColor;lightGrayColor;whiteColor;grayColor; redColor; greenColor; blueColor; cyanColor;yellowColor;magentaColor;  
  3. orangeColor;purpleColor;brownColor; clearColor; )   

自定義色彩:

  1. UIColor *newColor = [[UIColor alloc] initWithRed:(float) green:(float) blue:(float) alpha:(float)];      0.0~1.0   

寬度和高度

1
768X1024     1024X768    狀態欄高 20 像素高   導航欄 工具欄 44像素高

隱藏狀態欄:

  1. [[UIApplication shareApplication] setStatusBarHidden: YES animated:NO]   

橫屏:

  1. [[UIApplication shareApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight].  
  2. orientation == UIInterfaceOrientationLandscapeLeft  
  3. window=[[UIWindow alloc] initWithFrame:[UIScreen mainScreen] bounds];全屏   

自動適應父視圖大小:

  1. aView.autoresizingSubviews = YES;  
  2. aView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);   

定義按鈕

  1.  UIButton *scaleUpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];  
  2. [scaleUpButton setTitle:@"放 大"forState:UIControlStateNormal];  
  3. scaleUpButton.frame = CGRectMake(40, 420, 100, 40);  
  4. [scaleUpButton addTarget:self action:@selector(scaleUp) forControlEvents:UIControlEventTouchUpInside];   

設置視圖背景圖片

  1. UIImageView *aView;  
  2. [aView setImage:[UIImage imageNamed:@”name.png”]];  
  3. view1.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image1.png"]];  
  4.    
  5. UISlider *slider = (UISlider *) sender;  
  6. NSString *newText = [[NSString alloc] initWithFormat:@”%d”, (int)(slider.value + 0.5f)];  
  7. label.text = newText;   

活動表單 <UIActionSheetDelegate>

  1. - (IBActive) someButtonPressed:(id) sender  
  2. {  
  3.     UIActionSheet *actionSheet = [[UIActionSheet alloc]  
  4.                     initWithTitle:@”Are you sure?”  
  5.                     delegate:self  
  6.                     cancelButtonTitle:@”No way!”  
  7.                     destructiveButtonTitle:@”Yes, I’m Sure!”  
  8.                     otherButtonTitles:nil];  
  9.     [actionSheet showInView:self.view];  
  10.     [actionSheet release];  
  11. }   

正告視圖 <UIAlertViewDelegate>

  1.   - (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex  
  2. {  
  3.      if(buttonIndex != [actionSheet cancelButtonIndex])  
  4.      {  
  5.           NSString *message = [[NSString alloc] initWithFormat:@”You can  
  6.                    breathe easy, everything went OK.”];  
  7.           UIAlertView *alert = [[UIAlertView alloc]  
  8.                                initWithTitle:@”Something was done”  
  9.                                 message:message  
  10.                                 delegate:self  
  11.                                 cancelButtonTitle:@”OK”  
  12.                                 otherButtonTitles:nil];  
  13.           [alert show];  
  14.           [alert release];  
  15.           [message release];  
  16.      }  
  17. }   

動畫效果

  1.  -(void)doChange:(id)sender  
  2. {  
  3. if(view2 == nil)  
  4. {  
  5. [self loadSec];  
  6. }  
  7. [UIView beginAnimations:nil context:NULL];  
  8. [UIView setAnimationDuration:1];  
  9. [UIView setAnimationTransition:([view1 superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight)forView : self.view cache:YES];  
  10.    
  11.     if([view1 superview]!= nil)  
  12. {  
  13. [view1 removeFromSuperview];  
  14. [self.view addSubview:view2];  
  15.    
  16. }else{  
  17.    
  18. [view2 removeFromSuperview];  
  19. [self.view addSubview:view1];  
  20. }  
  21. [UIView commitAnimations];  
  22. }   

Table View <UITableViewDateSource>

  1.  
  2.  #pragma mark -  
  3. #pragma mark Table View Data Source Methods  
  4. //指定分區中的行數,默許為1  
  5. - (NSInteger)tableView:(UITableView *)tableView  
  6.  numberOfRowsInSection:(NSInteger)section  
  7. {  
  8. return[self.listDatacount];  
  9. }  
  10.    
  11. //設置每行cell顯示的內容  
  12. - (UITableViewCell *)tableView:(UITableView *)tableView  
  13. cellForRowAtIndexPath:(NSIndexPath *)indexPath  
  14. {  
  15. staticNSString *SimpleTableIndentifier = @"SimpleTableIndentifier";  
  16. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIndentifier];  
  17. if(cell == nil) {  
  18. cell = [[[UITableViewCell alloc]  
  19. initWithStyle:UITableViewCellStyleSubtitle  
  20. reuseIdentifier:SimpleTableIndentifier]  
  21. autorelease];  
  22. }  
  23.      UIImage *image = [UIImage imageNamed:@"13.gif"];  
  24. cell.imageView.image = image;  
  25.    
  26. NSUInteger row = [indexPath row];  
  27. cell.textLabel.text = [listData objectAtIndex:row];  
  28.      cell.textLabel.font = [UIFont boldSystemFontOfSize:20];  
  29.    
  30.      if(row < 5)  
  31. cell.detailTextLabel.text = @"Best friends";  
  32. else  
  33.     cell.detailTextLabel.text = @"friends";  
  34. returncell;  
  35. }   

圖象:如果設置圖象,則它顯示在文本的左邊

文本標簽:這是單元的主要文本(UITableViewCellStyleDefault 只顯示文本標簽)

詳細文本標簽:這是單元的輔助文本,通經常使用作解釋性說明或標簽

  1.  
  2.  
  3.   
  4.  
  5.  UITableViewCellStyleSubtitle  
  6. UITableViewCellStyleDefault  
  7. UITableViewCellStyleValue1  
  8. UITableViewCellStyleValue2  
  9.    
  10. <UITableViewDelegate>  
  11. #pragma mark -  
  12. #pragma mark Table View Delegate Methods  
  13. //把每行縮升級別設置為其行號  
  14. - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath  
  15. {  
  16. NSUInteger row = [indexPath row];  
  17. returnrow;  
  18. }  
  19. //獲得傳遞過來的indexPath值  
  20. - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath  
  21. {  
  22. NSUInteger row = [indexPath row];  
  23. if(row == 0)  
  24. returnnil;  
  25. returnindexPath;  
  26. }  
  27.    
  28. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  
  29. {  
  30. 生活不易,碼農辛苦
    如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
    程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 男女性刺激爽爽免费视频 | 国产精品久久久久久亚洲小说 | 91欧美激情一区二区三区成人 | 亚洲精选在线 | 老司机一二三区福利视频 | 中文字幕在线视频免费观看 | 国产成人免费在线视频 | 羞色影院| 在线免费观看中文字幕 | 国产亚洲视频在线观看 | 亚洲 欧美 国产 中文 | 免费播放观看在线视频 | videos欧美成人 | 国产中文欧美 | 国产免费久久精品99久久 | 欧美aa级| 国产精品乱码一区二区三区 | 久久国产精品成人免费 | 中文字幕国产在线 | 欧美成人全部免费观看1314色 | 国产精品福利网站 | 免费看成人国产一区二区三区 | 午夜视频入口 | 日本不卡一区二区三区四区 | 欧美 日韩 国产 成人 在线观看 | 亚洲精品一区二区久久 | 啪一啪在线视频 | 精品一区二区三区四区在线 | 刺激第一页720lu久久 | 成人永久福利在线观看不卡 | 最近新中文字幕大全高清 | 午夜欧美精品久久久久久久久 | 欧美深夜在线 | 亚洲在线第一页 | 国产精品亚洲午夜一区二区三区 | 久久精品在这里 | 成人社区网站 | 国产欧美第一页 | 亚洲区视频在线观看 | 欧美极品videosex性欧美 | 中文字幕视频二区 |