Used CollectionView-Simple sample code from apple. when run their project it works. But when run my project which is exactly same as apple sample code it doesn't shows images with grid layout but shows only navigation bar. Any idea why it is so.
Thanks for suggestions.
Check your dataSource and delegate for the UICollectionView in IB and make sure they are set just like the sample. More than likely you forgot to assign the delegate and dataSource to the UICollectionView.
Data Source and Delegate
You need to make sure that the collection view's dataSource and delegate are set properly.
If you are using Interface Builder, then make sure that you right-click drag* from the collection view to the little orange blob at the bottom of the scene. Repeat twice, once for both the Data Source and the Delegate.
If you are creating the view in code, you just need to say
self.cview.delegate = self;
self.cview.dataSource = self;
* AKA control-click
Related
Im using storyboard to create a collectionview which displays incoming Instagram Pics. Can someone take a look at my project to find out why it is not working?
*Edit The main issue lies in either the storyboard or the class called StreamViewController.m
The project was cut down for the most essential parts so dont worry about digging through a project.**
https://docs.google.com/file/d/0B9J0YAIS_BJPcFhvdzJ3LVV2Znc/edit?usp=sharing
I've looked through StreamViewController and you never set self as the delegate or datasource for "collectionView".
I have defined a UIView in the header file named rectangle0
I got a question in regards to IB vs coding a view. Please see the following code example:
rectangle0.frame = CGRectMake(0.0, 70.0, 320.0, 190.0);
Now I can re-create the look of the view easy enough in IB except for the coordinates which are greyed out.
So by calling this code in an IBAction after designing the UIView in IB I can display in the app.
[self.view addSubview:rectangle0];
Now the last line of code will call this view to appear at the set coordinates if I code it - but if I build in interface builder I can make it look exactly the same, but it appears from Y coordinate 20 (just under the status bar) and I can't set the coordinate upon calling it - is there a way to do this??
The UIView is being build outside of the ViewController and then linked to it in the connections inspector.
cheers Jeff
I have added an image to show what screen I am using - as you can see the x and y coordinates are greyed out, it would be great if I can set those to something else.
A view inside the NIB is just an object like any other. It is made to be reusable and I believe that is the key point that resulted in the coordinates being greyed out.
Greying out the position makes the developer worry about where is the view going to be placed. I say that because the position is pretty dependent on the container that your view object is going to be added to.
Although it is just my personal opinion and I am looking forward to hearing if there is indeed a way to do that.
You (effectively) said the view is managed by a view controller. Before you can resize the view, you need to change the Size setting in the view controller's Simulated Metrics to "Freeform". (It is probably set to "None" by default.)
I have some problems with the layout of my core plot graph.
To be more precise, I have created a GraphViewController (.h, .m and associated nib file). In the nib file I have added another UIView. This embedded view will be used to set the graph (as I do not want it to use the whole view). I then need to create a hosting view from this embedded view.
The embedded view is named graphView, I first though I needed to get the frame representing the graphView and create the hostingView so the graph will fit in the graphView. When I use the:
CPHostingLayerView *hostingView = [[CPHostingLayerview alloc] initWithFrame: [graphView frame]]
...
it does not work as expected, the graph does not fit the view (it is bigger than the graphView I created in IB)
Hope I am clear :(
Any idea would be more than welcome.
thanks a lot,
Luc
I finally find an answer :) Instead of adding an UIView within IB and programmatically create a CPLayerHostingView, I directly declared the view as an CPLayerHostingView in IB, that works perfectly.
Regards,
Luc
I was stuck with the same issue. What worked for me is a simpler way :
In super-view (where you are adding the core plot graph as a subview), add this code:
[self.subview.graphHostingView setFrame:self.view.bounds];
where subview is the view with the core-plot graph. And add this code 'after' you have done the graph initialization in the sub-view.
I'm very new to iPhone programming, and I'm currently following tutos to understand the whole thing. I've been able to do what I needed (retrive data from a JSON http server, parse them with YAJL and plot the data in core plot). I have done this in a "simple" view where I have added a UILayerHostingView as requested by core-plot.
I am now trying to follow this tuto: http://blogs.remobjects.com/blogs/mh/2010/01/26/p973 but I am missing the first part regarding the views...
My understanding is that I need to create a view with a UITableView first. Then add a UITableCellView to make the first cell be able to contain the graph ? Is this right ? Where does the method "(id)initWithStyle:(UITableViewCellStyle)style" come from ?
For my needs, only the first cell needs to contain a graph, I will put some other info in the other cells.
As for now, I have created a new GraphListViewController, in the corresponding view I have added a listview but I do not see any auto generated methods regading cell customisation ? Do I need to implements DataSource in this controller and manually add some customisation methods ? Do I need to add a UITagbleViewCell to this UITableViewTable within IB ?
Hope I am not getting to confusing...
Thanks a lot for your help,
Best Regards,
Luc
To start with, create a new file ...
Cocoa Touch Class -> UIViewController subclass
and click the UITableViewController subclass checkbox. This will do all the tableview work for you. You can now open the xib file and change all the properties that you want for this.
Once this is done you need to populate the cells within the table. The first thing you need to do is to tell the controller how many cells to display. For this update the numberOfRowsInSection: method to return how many you want.
The next part is where you want to create the cell and is done mainly in the cellForRowAtIndexPath and for this I'm gonna redirect you to the following good tutorial on adding custom cells.
http://iphonedevelopment.blogspot.com/2009/09/table-view-cells-in-interface-builder.html
This explains a bit of the 'magic' that happens
Hope this helps
Liam
Once a view is called from appdelegate, it is properly loaded but not autosized correctly, on the bottom you see last lines from previous view! On xib file, view mode property is set to scale to fill but I tried others and still happening the same... Thanks for any idea to solve it!
Maybe check Interface Builder, is the view using any of the Simulated User Interface Elements? That isn't directly answering your question but it might be worth a look, e.g. the status bar is normally simulated by default.
The standart way to control autosizing is by
self.View.autoresizingMask = UIViewAutoresizingFlexibleHeight(or st. else)
self.View.autoresizesSubviews = YES;
You might also try to just set the size manually