自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone開發(fā)之UISearchBar學(xué)習(xí)

移動(dòng)開發(fā) iOS
本文介紹的是iPhone開發(fā)之UISearchBar學(xué)習(xí),主要介紹了UISearchBar的使用,我們先來看內(nèi)容。

iPhone開發(fā)UISearchBar學(xué)習(xí)是本文要學(xué)習(xí)的內(nèi)容,主要介紹了UISearchBar的使用,不多說,我們先來看詳細(xì)內(nèi)容。關(guān)于UISearchBar的一些問題。

1、修改UISearchBar的背景顏色

UISearchBar是由兩個(gè)subView組成的,一個(gè)是UISearchBarBackGround,另一個(gè)是UITextField. 要IB中沒有直接操作背景的屬性。方法是直接將 UISearchBarBackGround移去  

  1. seachBar=[[UISearchBar alloc] init];  
  2. seachBar.backgroundColor=[UIColor clearColor];  
  3. for (UIView *subview in seachBar.subviews)   
  4. {    
  5.   if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])  
  6.        {    
  7.       [subview removeFromSuperview];    
  8.       break;  
  9.     }   

第二種解決的方法:

  1. [[searchbar.subviews objectAtIndex:0]removeFromSuperview]; 

2、

  1. UISearchBar* m_searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 44, 320, 41)];  
  2. m_searchBar.delegate = self;  
  3. m_searchBar.barStyle = UIBarStyleBlackTranslucent;  
  4. m_searchBar.autocorrectionType = UITextAutocorrectionTypeNo;  
  5. m_searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;  
  6. m_searchBar.placeholder = _(@"Search");  
  7. m_searchBar.keyboardType =  UIKeyboardTypeDefault;  
  8. //為UISearchBar添加背景圖片  
  9. UIView *segment = [m_searchBar.subviews objectAtIndex:0];  
  10. UIImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Images/search_bar_bg.png"]];  
  11. [segment addSubview: bgImage];  
  12. //<---背景圖片  
  13. [self.view addSubview:m_searchBar];  
  14. [m_searchBar release]; 

3:取消UISearchBar調(diào)用的鍵盤

  1. [searchBar resignFirstResponder];  

添加UISearchBar的兩種方法:

代碼

  1. UISearchBar *mySearchBar = [[UISearchBar alloc] 
  2. initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];          
  3.  mySearchBar.delegate = self;          
  4.  mySearchBar.showsCancelButton = NO;          
  5.  mySearchBar.barStyle=UIBarStyleDefault;          
  6.  mySearchBar.placeholder=@"Enter Name or Categary";           
  7. mySearchBar.keyboardType=UIKeyboardTypeNamePhonePad;           
  8. [self.view addSubview:mySearchBar];          
  9.  [mySearchBar release];    

在 tableview上添加:   

代碼  

  1. //add Table  
  2.         UITableView *myBeaconsTableView = [[UITableView alloc]   
  3.                                            initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-40)    
  4.   style:UITableViewStylePlain];  
  5.         myBeaconsTableView.backgroundColor = [UIColor whiteColor];  
  6.         myBeaconsTableView.delegate=self;  
  7.         myBeaconsTableView.dataSource=self;  
  8.         [myBeaconsTableView setRowHeight:40];  
  9.         // Add searchbar   
  10.         searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 40)];  
  11.         searchBar.placeholder=@"Enter Name";  
  12.         searchBar.delegate = self;  
  13.         myBeaconsTableView.tableHeaderView = searchBar;  
  14.         searchBar.autocorrectionType = UITextAutocorrectionTypeNo;  
  15.         searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;  
  16.         [searchBar release];  
  17.         [self.view addSubview:myBeaconsTableView];  
  18.         [myBeaconsTableView release];  

小結(jié):iPhone開發(fā)UISearchBar學(xué)習(xí)的內(nèi)容介紹完了,希望本文對你有所幫助。

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-08-10 10:10:21

iPhoneUIPopoverCo

2011-08-15 10:06:22

iPhone開發(fā)nib 文件

2011-08-08 10:10:14

iPhone開發(fā) 圖片 方法

2011-08-09 17:29:29

iPhone文件屏幕

2011-08-08 13:57:19

iPhone開發(fā) 打包 DEB

2011-08-11 10:03:43

iPhonecocoaNSRunLoop

2011-08-05 14:48:06

iPhone應(yīng)用 異步隊(duì)列

2011-08-18 10:39:46

iPhone開發(fā)界面

2011-08-08 14:57:46

iPhone Autoreleas Property

2011-07-18 14:39:53

iPhone SDK UIKit

2011-08-16 18:42:42

iPhone開發(fā)Release

2011-07-27 09:33:14

iPhone 網(wǎng)絡(luò) Web

2011-08-11 17:15:54

iPhone歸檔

2013-07-23 07:34:54

iOS開發(fā)學(xué)習(xí)適配iphone5

2011-08-22 13:46:15

iPhone開發(fā)GameKit 藍(lán)牙

2011-08-09 11:36:41

iPhoneUIPickerVieDEMO

2011-08-08 15:56:18

iPhone 震動(dòng) NSUserDefa

2011-07-27 16:46:04

iPhone iPhone破解 MacPort

2011-08-09 17:12:30

iPhoneCFRunLoop

2011-08-15 17:38:48

iPhone開發(fā)調(diào)試工具
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號