如何在ios中为联系人实现表视图中的搜索栏

如何在ios中为联系人实现表视图中的搜索栏,ios,objective-c,uitableview,xcode6,searchbar,Ios,Objective C,Uitableview,Xcode6,Searchbar,我在viewdidload中有以下代码 totalstring=[[NSMutableArray alloc]initWithObjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"n",@"o",@"p",@"q",@"r",@"s",@"s",@"t",@"u",@"v",@"w",@"x",@"y",@"z", nil]; indid=indidvalue1; NSLog(@

我在viewdidload中有以下代码

totalstring=[[NSMutableArray alloc]initWithObjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"n",@"o",@"p",@"q",@"r",@"s",@"s",@"t",@"u",@"v",@"w",@"x",@"y",@"z", nil];





indid=indidvalue1;

NSLog(@"the ind id value is %@",indid);

serviceCall=[[Services alloc]init];

NSString *contactsDisplay1=@"ContactDetails";

NSDictionary *contactsDisplayDetails1 =@{@"IND_ID":indid};

[serviceCall ContactsDisplayUrl:contactsDisplay1 ContactsDisplayDetails:contactsDisplayDetails1];
[serviceCall setDelegate:self];
实现搜索栏的代码

{


    filteredstring =[[NSMutableArray alloc]init];

    for (NSString *str in totalstring )
    {

     NSRange stringrange =[str rangeOfString:searchText options:NSCaseInsensitiveSearch];

        if(stringrange.location!= NSNotFound)
        {
            [filteredstring addObject:str];
        }
    }
}
[tableView reloadData];
表格视图代码

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

if (cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
}
if (tableView == self.searchDisplayController.searchResultsTableView)
{
    cell.textLabel.text = [searchResultsArray objectAtIndex:indexPath.row];
} else
{
    UIFont *myfont=[UIFont fontWithName:@"Arial" size:35];
    cell.textLabel.text = [contactNameSplitDisplayArray objectAtIndex:indexPath.row];
    cell.detailTextLabel.text=[relationTypeSplitDisplayArray objectAtIndex:indexPath.row];
    cell.textLabel.font=myfont;
}
return cell;
我如何在表格视图中为故事板中的联系人实现搜索栏?我是iOS新手 ?
以及如何在表格视图中实现加号按钮和点按钮?

请参考下面的链接,我可以使用此按钮在表格视图中实现搜索栏


请参考下面的链接,我可以使用此链接在表视图中实现搜索栏


Devi是我的完整答案。它工作得很好。我使用搜索栏。也使用委托方法

ViewController.h

#import <UIKit/UIKit.h>
#import <Contacts/Contacts.h> //Must import contact framework 

@interface ViewController :  UIViewController<UISearchBarDelegate,UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UISearchBar *searchbarContacts;
@property (strong, nonatomic) IBOutlet UITableView *tableViewContactData;
@end

Devi是我的完整答案。它工作得很好。我使用搜索栏。也使用委托方法

ViewController.h

#import <UIKit/UIKit.h>
#import <Contacts/Contacts.h> //Must import contact framework 

@interface ViewController :  UIViewController<UISearchBarDelegate,UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UISearchBar *searchbarContacts;
@property (strong, nonatomic) IBOutlet UITableView *tableViewContactData;
@end

选中此项可能有助于youDevi我在此处发布了全部代码。您可以使用。我使用委托方法实现了搜索栏。如果您搜索名称(keta、anna、a、n、john、j、h…等),它向您显示结果。发布答案比提供链接好。检查此选项可能会对您有所帮助。我在此处发布了整个代码。您可以使用。我使用委托方法实现了搜索栏。如果您搜索名称(keta、anna、a、n、john、j、h…等),它会向您显示结果。发布答案比提供链接好。您在此处调用搜索栏委托,self。searchbarContacts.delegate=self;没有呼叫代表,搜索栏乐趣将如何呼叫。在我的例子中,我在uitableview中的搜索栏,如何在表视图类中调用该委托…在这里您调用了搜索栏委托,self。searchbarContacts.delegate=self;没有呼叫代表,搜索栏乐趣将如何呼叫。在我的示例uitableview中的搜索栏中,如何在表视图类中调用该委托。。。
The contactsArray are - (
"John Appleseed",
"Kate Bell",
"Anna Haro",
"Daniel Higgins",
"David Taylor",
"Hank Zakroff"
)