如何在iOS swift4中使用适当的联系人按姓名过滤联系人

时间:2018-11-19 05:48:14

标签: ios iphone swift

我有public class AttachmentGridAdapter extends RecyclerView.Adapter<AttachmentGridAdapter.ViewHolder> { List<Attachments> item = new ArrayList<Attachments>(); Context context; private static LayoutInflater inflater=null; private Typeface fontFamily; public AttachmentGridAdapter(Context activity, List<Attachments> arrayList, Typeface fontFamily) { item=arrayList; context=activity; this.fontFamily=fontFamily; inflater = ( LayoutInflater )context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.grid_attachment, parent, false); final ViewHolder vh = new ViewHolder(v); return vh; } @Override public void onBindViewHolder(final AttachmentGridAdapter.ViewHolder gridHolder, final int position) { gridHolder.gridAttachmentItem=item.get(position); try { Bitmap bitmap = null; try { bitmap = retriveVideoFrameFromVideo(gridHolder.gridAttachmentItem.getUrl()); } catch (Throwable throwable) { throwable.printStackTrace(); } if (bitmap != null) { bitmap = Bitmap.createScaledBitmap(bitmap, 240, 240, false); gridHolder.imgAttachment.setImageBitmap(bitmap); } }catch (Exception e){ e.printStackTrace(); } } @Override public int getItemCount() { return item.size(); } public class ViewHolder extends RecyclerView.ViewHolder { Attachments gridAttachmentItem; ImageView imgExpAttachment; public ViewHolder(View itemView) { super(itemView); imgExpAttachment=(ImageView) itemView.findViewById(R.id.imgExpAttachment); } } public static Bitmap retriveVideoFrameFromVideo(String videoPath) throws Throwable { Bitmap bitmap = null; MediaMetadataRetriever mediaMetadataRetriever = null; try { mediaMetadataRetriever = new MediaMetadataRetriever(); if (Build.VERSION.SDK_INT >= 14) mediaMetadataRetriever.setDataSource(videoPath, new HashMap<String, String>()); else mediaMetadataRetriever.setDataSource(videoPath); bitmap = mediaMetadataRetriever.getFrameAtTime(1, MediaMetadataRetriever.OPTION_CLOSEST); } catch (Exception e) { e.printStackTrace(); throw new Throwable( "Exception in retriveVideoFrameFromVideo(String videoPath)" + e.getMessage()); } finally { if (mediaMetadataRetriever != null) { mediaMetadataRetriever.release(); } } return bitmap; } } 个联系人,其中包含姓名和电话号码。我需要按姓名过滤该联系人。其过滤名称,但不包括各自的编号。我正在使用此链接执行此任务https://www.journaldev.com/14126/ios-uisearchcontroller-uitableview

但是它具有

之类的模型
UITableView

我正在从服务器获取models = [ Model(name:"The Dark Night", number:"Action"), Model(name:"The Avengers", number:"Action"), Model(name:"Logan", number:"Action"), Model(name:"Shutter Island", number:"Thriller"), Model(name:"Inception", number:"Thriller"), Model(name:"Titanic", number:"Romance"), Model(name:"La la Land", number:"Romance"), Model(name:"Gone with the number", genre:"Romance"), Model(name:"Godfather", number:"Drama"), Model(name:"Moonlight", number:"Drama") ] nameArr。我不能像名称:“ Moonlight”,数字:“ Drama”那样拆分。如何传递数组而不是像这样手动定义?

0 个答案:

没有答案