سؤال

I am looking for a way to load an image from my disk into a CPImageView. Is this possible?

هل كانت مفيدة؟

المحلول

To upload an image to a server, you could either use a normal file upload button such as what is implemented by FileUpload. Or, if you're not afraid of some potentially very tricky cross browser problems you could try to use my fork of Deep Drop Upload which allows drag and drop upload.

In either case, once the image is on your server you need your server to return the URL of where the image can be viewed. Let's say this URL is http://example.com/uploads/image101.png. Then you can display it in a CPImageView the normal way:

var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[imageView setImage:[[CPImage alloc] initWithContentsOfFile:"http://example.com/uploads/image101.png"]];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top