Reload all UIImageViews on current screen - uiimageview

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.

Related

Handling Multiple UIImageViews Together

I have UIImageViews in three different view controllers displaying the same thing, that being user's profile pic. I want them all to update at the same time when the user changes his/her profile pic using imagepickercontroller. I thought about outlet collection, but I believe they don't work across different view controllers. I am out of ideas on this one, any help would be greatly appreciated. Thanks.
I think there are few solutions for your problem. One of them is using your profile image as global variable. Then whenever you move to a viewcontroller, in their viewWillAppear, assign the profile image to the UIImageViews.
It's simple, isn't it?

uicollectionviewcell doesn't get selected

My app is based on a navigation controller that contains a a custom view controller which embed two view controllers.
The first one is an UICollectionViewController for which I have designed the cell via IB.
Cell contains an imageview and a label.
On the execution the app shows correctly all the cells with their images and related labels, but only some of them trigger the DidSelect event when you touch them.
I have tried to change the cell position on the screen changing the interspace setting within IB, and in this way some of the cells that before were "insensitive" now are sensitive and vice versa.
I have also checked that both image and label are user interactive.
Any suggestions?
Many thanks
I made a simple mistake: in the container view I inserted two views, the view containing the UICollectionViewController is below the other, whose content, most of the time, is hidden, but I set hidden the view contained not this specific one.

Advice needed for developing multiple window Mac application

I’ve been reading through several books on Mac development, but cannot find the information I’m looking for.
The books all describe how to make floating windows or panes, but never mention how to make them all in one window. A simplified example of what I’m looking to create is shown below:
Basically, there will be three windows; A selector window with radio buttons to choose which NSDocument is currently being used, a window underneath that with buttons that show different windows to the right that allow viewing and manipulation of certain data.
For a example, each NSDocument may have a color value that can be set in the window shown by clicking view A, and some text strings that can be set in the window shown by clicking view B.
So the questions are:
Is it appropriate to use a single NSDocument sub-class for each Doc #1 and Doc #2?
Which classes should I use to set up the application as shown? NSWindowController? NSWindow? NSPanel?
I’m only looking for guidance on what to read up on, so any pointers are appreciated.
EDIT:
To clarify this further, I want to have a table view where the buttons are (View A & B), and by clicking them they will cause the other window/view to change it's contents.
It's like the split view in the iPad settings application, there is a table view on the left, and when it's pressed the right side changes.
The radio buttons are there only to illustrate that I want more than one Document. I'm guessing I need more than one to handle this? Or perhaps I should place them all in a single NSDocument? Somehow that doesn't seem right.
To achieve what you want you need one window (NSWindow), one window controller and various views each with their own view controller. There are several ways you could set this up, all depending on your requirements:
You'd have at least 3 views (instances of NSView): one for the selection of the document class, one for the view selection and one for the content. Each view is controlled by a view controller (instance of NSViewController). Additionally you can opt to wrap the views in split views (NSSplitView) so your user can resize the real estate available to each view.
You have one window with a window controller. If you choose a Document based app template in Xcode, Xcode will generate a subclass of NSDocument which you can use as your window controller (or choose to use Core Data and Xcode will generate a subclass of NSPersistentDocument with all bells and whistles you need to access Core Data for document persistency).
So to come back to your questions:
1: Yes, but depending on your requirements. If Doc #1 is a completely different thing than Doc #2 than you might need to re-evaluate. For example Doc #1 might have completely different persistent requirements than #2.
2: There's no single scenario here, but one that worked for me: Take the project template for a document based app (with or without Core Data). Use the generated subclass of NSDocument (or NSPersistentDocument) as your window controller. Use NSView to implement the views in your window where each view is managed by its own controller, which is an instance of NSViewController.
I know this is an old question, but a way to do it how you want would be to use: ContainerViews and set their embed segue to be the view controllers you want.

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.

Updating a single image of an IKImageBrowserView

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.

Resources