ios - iPhone how can i apply a pdf file as image on a table view cell -


i working on project in have put images on table view cells. possible put .pdf format files on table view cells image?

i used following code:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];      if (!cell)     {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier];     }   //  nsdictionary *menuattr = [menuitems objectatindex:indexpath.row];        //  cell.textlabel.text = [nsstring stringwithformat:@"%@", [menuattr objectforkey:@"name"]];       if (indexpath.row ==0 )     {         cell.imageview.image = [uiimage imagenamed:@"about us.pdf"];            cell.imageview.layer.cornerradius =cell.imageview.image.size.width/2;     }     if (indexpath.row == 3)     {         cell.imageview.image = [uiimage imagenamed:@"policies.pdf"];     }     if (indexpath.row == 2)     {         cell.imageview.image = [uiimage imagenamed:@"services.pdf"];     }         if (indexpath.row == 1)     {         cell.imageview.image = [uiimage imagenamed:@"home.pdf"];     }      if (indexpath.row == 4)     {          cell.imageview.image = [uiimage imagenamed:@"contact us.pdf"];     }      if (indexpath.row == 5)     {          cell.imageview.image = [uiimage imagenamed:@"feedback.pdf"];     }      [tableview setseparatorstyle:uitableviewcellseparatorstylenone];      cell.backgroundcolor = [uicolor clearcolor];     [cell setselectionstyle:uitableviewcellselectionstylenone];     cell.contentview.backgroundcolor = [uicolor clearcolor];     return cell; } 

yes, sure can, it's going give shot of first page of pdf ... thumbnail. here's how it:

  1. create assets folder in xcode:

enter image description here

  1. place pdf files assets catalog:

enter image description here

  1. change image it's correct format, on right side of picture, have change 5th drop down on side "single vector":

enter image description here

  1. drag image correct slot, in previous image see yellow warning marker? happens because image isn't in correct slot, have drag pdf file slot above correct this:

enter image description here

  1. you can use pdf vector file this:

    [_window setbackgroundcolor:[uicolor colorwithpatternimage:[uiimage imagenamed:@"examplepdf"]]]; 

i use vectorized pdfs in apps. system resizes these correct iphone , ipad sizes itself, no need use @2x or @3x or else.

here's additional tutorial on how works:

http://martiancraft.com/blog/2014/09/vector-images-xcode6/

you should first save pdf files in illustrator explained in tutorial above, either way, method should work. luck!

here's output small tutorial explained above:

enter image description here


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -