成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

iPhone開發(fā)之UISearchBar學習

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

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

1、修改UISearchBar的背景顏色

UISearchBar是由兩個subView組成的,一個是UISearchBarBackGround,另一個是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];  

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

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

2011-08-10 10:10:21

iPhoneUIPopoverCo

2011-08-08 10:10:14

iPhone開發(fā) 圖片 方法

2011-08-15 10:06:22

iPhone開發(fā)nib 文件

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應用 異步隊列

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-07-27 09:33:14

iPhone 網(wǎng)絡 Web

2011-08-11 17:15:54

iPhone歸檔

2011-08-16 18:42:42

iPhone開發(fā)Release

2011-08-09 11:36:41

iPhoneUIPickerVieDEMO

2011-08-22 13:46:15

iPhone開發(fā)GameKit 藍牙

2013-07-23 07:34:54

iOS開發(fā)學習適配iphone5

2011-07-27 11:14:37

iPhone UITableVie

2011-07-27 16:46:04

iPhone iPhone破解 MacPort

2011-08-08 15:56:18

iPhone 震動 NSUserDefa

2011-08-09 17:12:30

iPhoneCFRunLoop
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 久草新在线 | ririsao久久精品一区 | 国产高清精品在线 | 国产在线视频在线观看 | 精品丝袜在线 | 日韩在线观看一区 | 欧美一区二区三区高清视频 | a视频在线观看 | 野狼在线社区2017入口 | 欧美一区二区三区在线播放 | 拍拍无遮挡人做人爱视频免费观看 | 亚洲精品女人久久久 | 日本aa毛片a级毛片免费观看 | 成年人在线 | 激情综合五月天 | 成人免费看| 国产精品国产精品国产专区不卡 | 一级欧美日韩 | 久久国产精品一区二区三区 | 亚洲精久久 | 高清亚洲 | 国产999精品久久久久久 | 免费同性女女aaa免费网站 | 欧美一二三 | 精品久久久久久久久久久院品网 | 亚洲欧美日韩在线 | 天天色综网 | 在线观看国产视频 | 日韩一及片 | 久久久一区二区三区 | 久久精品99久久 | 亚洲一区成人 | 日韩在线成人 | 久久精品黄色 | 亚洲美女在线视频 | 久久99久久久久 | 91麻豆精品一区二区三区 | 伊人免费在线观看 | 亚洲一区不卡在线 | 精品入口麻豆88视频 | 欧美日韩中文在线观看 |