UICollectionView in view controller - objective-c

I am looking for a possibility to drag and drop an image in a collection view cell to a UIImageView in the same view controller but outside of the collection view. The cv is below 5 collection views and i want to drag the image in the collection view and drop it into one of the 5 UIImage Views above the collection view. Is there a possibility to take the image from the collection view cell and reorder the collection view in new order so that the token dragged image (and cv-cell) will be deleted below? The images in the colectionview come from urls via json load. I am working with storyboard and with ARC ...
Thanks a lot for any help or tipps!

Maybe you could load the images of the collection view inside an NSMutableArray, which you can run through in order to get the data your collection view must show. When you drag it from the collection view into the UIImageView, remove the correspondent index of that image inside the NSMutableArray and reload the collection view data. At the same time you get that image data and load it to the image view. This could help if I understood your problem.

Related

Connection for label/image view outlet for collectionViewCell not populating. ( no errors)

I am trying to connect a label and image view outlet for a collection view cell with control drag, since each photo and label will be different. I have already done this before with a previous view controller. However this time when I try to get the outlets to connect to the cell class. It is not populating. Is there any reason why this is happening?
I also want to note that this view controller will be connected to another view controller I previously made that also uses a collection view. Could this be the reason why I am having this problem? I already created another view controller class and connected the collection view datasource and delegates. I also tried connecting the label and image view to my other collection view cell class that worked for the other collection view cell and it won't even populate there.
Worked fine with my first collection view
When I drag it doesn't populate outlet connection
Ahh, so I forgot to set the actual cells custom class property.
That fixed it.

UICollectionView - start viewing from a particular indexpath

I am creating a UICollectionView with paging enabled. Each collection view cell is a full screen image. By default I am able to view the cells from the index 0 (first cell). But I want to start viewing cell from a particular cell index. Can anybody tell me how to do that?
Got it working.
From the first view controller pass the index path of photo to which you have to scroll. In the ViewDiDLoad of your collection view set up the collection view and then use the method - scrollToItemAtIndexPath:atScrollPosition:animated: Set animated to NO and atScrollPosition to UICollectionViewScrollPositionNone

Create UIPopOver without including Tableview in ios

I want to create two PopOvers when at the time button clicked and textField clicked in the same UIView (not ViewController). In those popovers I need to load separate array values. Is there any way to create them and added to UIView?
I already added one tableview for base UIView, so without using tableviews, how can I create UIpopOvers and load the arrays in those popOvers? How to handle the selected rows?
This link can help you to create a popover menu.
Or you can take an UIImageView having shape of popover menu and table view in that, it will be easy to load arrays and to handle selected rows.
I did the same using second method.
Happy Coding!

iOS Split View - Load XIB

I am new to making iOS apps. I want to make a Split View app so I can have topics on the left and the content on the right.
I want to be able to pull the xib file and display it on the right. How can I do this?
I have a basic one working where it changes image, but not views. I want to display the xib file relating to the selected one in the array. Any tutorial to show me how to do this would be great.
Here is the video I watched.
P.S I am new to this app development. Thanks.
A split view controller manages two view controllers.
When you create a view controller, you can specify the .xib file from which it should load its view.
It follows, then, that when the user taps on a topic, your code can create a corresponding view controller (see UIViewController's -initWithNibName:bundle: method) and set that view controller as the split view controller's detail view controller.
It's possible to have an existing view controller load a new view from a .xib using NSBundle's -loadNibNamed:bundle:owner: method, but that's usually more work with no real advantage over replacing the entire view controller.
As far as I remember, you should have access from your viewController to the property splitViewController, on which you can change the property "viewControllers" to any array containing the rootViewController at index 0 and the detailViewController (set to your new detailViewController) at index 1.
If you don't want to have sveral controller for your views, I remember having used NSBundle methods to load a nib file and assign it to a controller. I believe this is another possibility but you have to test it.

Data not loading to detail view controller when first row selected

When I launch the app in question I load up a table from an array derived from a plist. In didSelectRowAtIndexPath I assign values from the array to sub views in detail view controller and then push the detail view controller onto the stack, but when running the app, the first time I select any row from the table, data from the array does not appear in my detail view controller's subviews/fields. I then click back to the table view, re-select the row and the data then loads in the detail view controller.
In the table view controller didSelectRowAtIndexPath method I do the following where xLabel is the UILabel sub view in the pushed view controller's xib:
self.detailViewController.xLabel.text = [[[xArray objectAtIndex: indexPath.section] objectForKey:#"xDesc"] objectAtIndex:indexPath.row];
What do I need to do to have the data appear the first time a row is selected?
I think this is not working because first time when you select a row your detail view controller is not there in memory stack, so you can not call setText method of a label in previous view controller. Second time its working because its there in memory so you can call set method to its component. What i want to say it that when you are pushing detail view controller in stack just set a string of detail view controller here (this string should be property of detail view controller) and then in detail view controller's viewDidLoad method set the text of your label to this string.
If i understood you correctly, there is no xLabel object the first time around as it will be created when the UIViewController is being "loaded". So, when you try to set the text value, it isnt loaded into the label, as there is no label. Subsequent attempts work as the label is created from the first attempt. Anyways, if you need to share some data with the detail view, store then in a dictionary or some other object rather than just assigning it directly to the view from the current controller.