Updating a single image of an IKImageBrowserView - cocoa

I searched everywhere and can't seem to find a way to do this.
I am currently making a simple application to help our user configure image metadata for another application.
I present the list of image to be configured in an IKImageBrowserView. The user selects an image. which is then displayed in another view and adds stuff to it.
I'd like to be able to update the IKImageBrowserView thumbnail "live", as the user manipulates the image. I am able to take a "screenshot" of the view on which he is working but can't for the life of me find a way to update this single IKImageBrowserView item without having to call reloadData.
Is there a way to update a single image in an IKImageBrowserView without calling reloadData?
Thanks!

Look at the -imageVersion method. This will cause the cache for that item to be invalidated. There also appears to be a private -reloadCellDataAtIndex: method that might be of interest. Updating the image's version and calling -reloadData should be sufficient though.

Related

Reload all UIImageViews on current screen

I'm making an iOS app that shows profile images of friended users on a single page. There might be more than one identical profile image for each user displayed on the same page at any one time. The images are subviews of various custom views. Long pressing on one of the images allows the user to change it. After they have done so, all identical profile images on that page (x number of images) should be changed to the new image.
How can I get all UIImageViews on the page that contain the same profile image to update, without having to set each one individually?
Ideally, I would like to 'reload' the view controller, but I can't find a way to do this. I have tried using setNeedsDisplay(), but it doesn't work.
I'm new to iOS development.
OK, I solved this by subclassing UIImageView and adding a 'user' instance property and an array of all initialized instances as a static property. Now when a profile image is changed in one imageView, I can iterate over all instances and swap out any that belong to the same user.

How to show a collection of images in visualworks smalltalk GUI

I want to load a collection of images and show them in the GUI like an instagram or something like that, How can I reach this?
Which widget should I use?
I've tried creating a ViewHolder in the GUI but I don't know how should I assign it the image to display.
Using a view-holder is a good start. The view holder operates on a View object. This object needs to be a subclass of View and you store the instance in your application model in an instance variable. The accessor of that instance variable needs to be used in the UIPainter, so that the ViewHolder knows how to access its view.
Now in that View subclass you need to implement #displayOn:, which gets a GraphicsContext as parameter. That GraphicsContext has a clippingRect, which you should make use of in order to determine which image to draw. To draw the images you typically send #displayOn: to the image, but there's probably also a #displayOn:at: method available.
You may also want to tell that view holder that it has scroll bars.
In general it would be also a good idea to have a look at the GUIDevGuide.pdf in the doc folder of your VisualWorks installation. It'll describe the ViewHolder and its usage step by step.

How to check if Image is loaded while coming back in Navigation stack

In my MainPage I have added many images, each of them is retrieved from server by making HttpWebRequest. Also there are some links on MainPage, clicking on those links takes the user to a new page.
The problem I am facing is before all the images are loaded in the MainPage itself, if I click on any of the links on the MainPage, a new page is created and shown and all the pending image requests are canceled. Now If I come back to MainPage by clicking on the back button, the unloaded images still remain unloaded.
I have no idea how to check whether the images have already been loaded or not, when I come back to MainPage in the navigation stack(If I am able to find out that some images are not loaded, I can request the server again for the unloaded images). I need a generic solution for this. Because parent child relationship in the MainPage content layout is dynamic, means I do not know the hierarchy of the Image control, Image control can be a child of a canvas which in turn added to the MainPage's Content grid or the image can be added in one of the sections of a panorama/pivot which in turn added to the MainPage's Content grid, etc,....
There is an event on the Image control related to that -> http://msdn.microsoft.com/en-us/library/system.windows.controls.image.imageopened(v=vs.95).aspx
As argh suggested use the ImageOpened event (and perhaps also ImageFailed) to track whether the image has been loaded successfully. You could create a wrapper control around Image (can't inherit since it is sealed) to monitor the event and implement your own IsLoaded property.
You can use VisualTreeHelper.GetParent to traverse up through the tree and see whether the Image control is a descendant from MainPage for the second part of your problem.
This should work, however, I'm wondering why the images are not re-loaded when you press the back button. I don't think any of the suggested 'hacks' should be necessary. Are you using any custom logic for image loading etc.?
You can check Name of Image Temp . beacause in my project i use image temp show before image has load in server.
You can check the current name of the Image, if it is similar to the Temp Image name, then continue down they will not down
My code :
if(((BitmapImage)img.Source).UriSource.Equals("/NhomMua;component/Image/img_temp_sale.png"))
{
//code of you
}
I would suggest you have a look at the LowProfileImageLoader http://blogs.msdn.com/b/delay/archive/2010/09/02/keep-a-low-profile-lowprofileimageloader-helps-the-windows-phone-7-ui-thread-stay-responsive-by-loading-images-in-the-background.aspx) as a generic way to handle loading of images in an efficient manner. If you specifically need to be able to cancel and resume the loading of images you should able to modify that code to handle that pretty easily - although I'm not sure why you'd want to, remember its more efficient on the battery to download all the images in one hit than to stop and start.

Changing selection state of IKImageBrowserView

Hey guys, I've just migrated my image selector from NSCollectionView to IKImageBrowserView. I've got almost everything set up the way I want it, except for the selection ring. I don't like the greyed out background that IKImageBrowserView defaults to, and I wanted to do a yellow stroke around the edge of my selected image to indicate it's selection (like in iPhoto). Is is possible to override the draw state of IKImageBrowserCell? I haven't been able to find any way to do it yet. It doesn't have the simple drawRect methods that I'm used to. Any help would be appreciated. I'm assuming I have to use CALayers?
I overrode - (CALayer *)layerForType:(NSString *)type and tried just as a test, setting the layer corner radius to 0, but it didn't seem to change anything. The method is being called because if I throw a breakpoint in it, it stops there. However, even if I return nil from that method, it still draws the images like usual.
Thanks!
That is the right method for customizing the IKImageBrowserCell.
Using CALayers and configuring different attributes, you can control many facets of how the images are presented.,
A layer of type = IKImageBrowserCellSelectionLayer is what you will want to change to have the display behave and present as you wish.
Here's a link to Apple's sample code project that will get you started

How can my code get notified when the user pastes or drags an image into NSImageView?

I have an instance of NSImageView. I have told InterfaceBuilder to allow the user to paste or drag an image into this view. This works. However, I don't see a way in the NSImageView or related documentation to get notified when this actually happens. I was expecting a delegate or some such, but I have been unable to find it. Any ideas?
This is what Cocoa Bindings does best.
Instead of talking to the view, simply have a property whose value is an image, and bind the image view's image binding to it; then, when you want to change the image in the image view yourself, all you have to do is set the value of the property, and the image view will notice the change.
The user pasting or dragging into the image view is essentially the same thing, partly in reverse: The paste or drop will change the value of the image view, which will then set the value of your property, which will cause anything else bound to it to notice the change and pick up the new value as before.
Aside from ripping out your existing send-explicit-messages-to-views code, this will require almost no code work: The only code you need is for your property. You'll hook up the Binding in IB.
See the Key-Value Coding Programming Guide and the Cocoa Bindings Programming Topics.
As for me the better way to override function
-(void)paste:(id)sender
But only if you have it in NSView based class which has NSResponder as parent

Resources