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:
- create assets folder in xcode:
- place pdf files assets catalog:
- change image it's correct format, on right side of picture, have change 5th drop down on side "single vector":
- 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:
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:
Comments
Post a Comment