Skip to content

Commit

Permalink
+ [search] 完善搜索功能
Browse files Browse the repository at this point in the history
  • Loading branch information
coderyi committed Nov 6, 2016
1 parent 8464353 commit 6b1f0fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//

#import "SearchDataSource.h"
#import "RankTableViewCell.h"
#import "RepositoriesTableViewCell.h"

@implementation SearchDataSource

Expand All @@ -23,37 +25,40 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
if (tableView.tag==11) {
RankTableViewCell *cell;
NSString *cellId=@"CellId1";
cell=[tableView dequeueReusableCellWithIdentifier:cellId];
if (cell==nil) {
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
cell=[[RankTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
UserModel *model = [(self.DsOfPageListObject1.dsArray) objectAtIndex:indexPath.row];
cell.textLabel.text=model.login;
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:model.avatar_url]];
cell.imageView.layer.masksToBounds=YES;
cell.imageView.layer.cornerRadius=8;
cell.mainLabel.text=model.login;
[cell.titleImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar_url]];
return cell;

}else if (tableView.tag==12){

RepositoriesTableViewCell *cell;

NSString *cellId=@"CellId2";
cell=[tableView dequeueReusableCellWithIdentifier:cellId];
if (cell==nil) {
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId];
cell=[[RepositoriesTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
RepositoryModel *model = [(self.DsOfPageListObject2.dsArray) objectAtIndex:indexPath.row];

cell.textLabel.text=[NSString stringWithFormat:@"%@",model.full_name];
cell.detailTextLabel.text=[NSString stringWithFormat:@"%@ %@",model.language,model.repositoryDescription];
cell.detailTextLabel.textColor=YiTextGray;
cell.repositoryLabel.text=[NSString stringWithFormat:@"%@",model.name];
cell.userLabel.text=[NSString stringWithFormat:@"Owner:%@",model.user.login];
[cell.titleImageView sd_setImageWithURL:[NSURL URLWithString:model.user.avatar_url]];
cell.descriptionLabel.text=[NSString stringWithFormat:@"%@",model.repositoryDescription];
[cell.homePageBt setTitle:model.homepage forState:UIControlStateNormal];
cell.starLabel.text=[NSString stringWithFormat:@"Star:%d",model.stargazers_count];
cell.forkLabel.text=[NSString stringWithFormat:@"Fork:%d",model.forks_count];
return cell;
}
return cell;
return nil;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ - (void)viewDidLoad
[self segmentAction:buttonTag];
};
self.navigationItem.hidesBackButton =YES;
mySearchBar=[[UISearchBar alloc] initWithFrame:CGRectMake(10, 2, ScreenWidth-80, 40)];
mySearchBar=[[UISearchBar alloc] initWithFrame:CGRectMake(10, 2, ScreenWidth-90, 40)];
[self.navigationController.navigationBar addSubview:mySearchBar];
mySearchBar.delegate=self;
mySearchBar.tintColor=YiBlue;
Expand Down Expand Up @@ -229,6 +229,13 @@ - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
}

#pragma mark - UITableViewDataSource &UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.tag==11) {
return RankTableViewCellHeight;
}
return RepositoriesTableViewCellheight;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Expand Down

0 comments on commit 6b1f0fe

Please sign in to comment.