In lots of apps that have a feed every now and then the users are presented ads. I am assuming these adds are placed in their own cells of a UICollectionViewController. How does one add such ads to ones app in a randomly inserted cell between two existing cells without replacing either of them?
I have found a solution. Its not pretty but here it goes:
I have changed the height of every 5th cell to have space for implementing ads. Therefore I am not overwriting an already existing cell only populating an already existing cell with more data.
Once I have found a better solution I will let you know but this is it for now, if anyone comes across the same problem
Related
i am working on an app that lets the user enter some information which then gets loaded online. As part of my project, i want the user to enter some information and it would be alot easier for them if there was a table allowing them to enter it , ok so the problem is, I have a view controller with a scrollview which gives me some more space i can work with.
I want a way where i can display a table 5 columns across and the rows will depend upon the user, the table should only take a small amount of space on the scrollview, the table will allow information to be entered into the cell which later will be saved. i just need a point in the right direction on how to go about this problem. I am fairly new to swift and any guidance would be much appreciated, thanks in advance
Based on your requirement of having both columns and rows—I would look into creating a UICollectionView and populating the cells with UITextFields.
Please learn about UITableviewController here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewController_Class/
There are no columns, just rows, and you don't need an extra scrollview to contain your tableview in. There are plenty of tutorials out there that teach how to work with table view controllers. You should seek guidance here if you have a particular problem with implementing them.
So, I'm a bit of a noob to iOS (PHP dev). I have a UITableView in a UIViewController. The cells consist of a combination of any of three different custom prototype cells. Which cells are loaded is based on a service that loads the questions and types. One has a segmented control with 2 choices, another with 8 choices and the third has a UITextView to receive a comment. This is essentially a survey. I can grab the values of the controls as they are answered, but I'd like to be able to just gather them up when the 'submitResponses()' method is called as an action attached to the 'Submit' button.
Any ideas? Should I be going about this in another way?
The "correct" way to do this is definitely to collect the data as it is entered!
One of the biggest problems with the approach that you suggest is that for larger tables it simply won't work because if a table view cell is off the screen, you can't access it or the controls/views that it contains (and it may not even exist yet!).
I'm working on a real estate app. The app query a datafeed server after user fill in a form (min rooms, price and so on) and it gets a json string with specific key/value pairs (property name,property address,longitude/latitude,price,etc...).
What I'm trying to do is allowing the user to browse the listing in a UITableView even if the feed contains a long list of items without having to overload the user iphone (the returned items count is not known before the query is done, so the app need to handle this)...What would you suggest me for paging ?
Thx in advance,
Stephane
If your tableView:cellForRowAtIndexPath: method is written correctly using dequeueReusableCellWithIdentifier: (and you don't use tableView:heightForRowAtIndexPath:, or it is very fast), UITableView should be able to handle thousands of rows without overloading the device. You just need to be concerned with the storage of your raw data.
As for your problem of not knowing the number of rows until the query is complete, that is easy enough to work around. As you receive more rows from the query, just use UITableView's insertRowsAtIndexPaths:withRowAnimation: to inform the table view that more rows are available (and be sure that your tableView:numberOfRowsInSection: and tableView:cellForRowAtIndexPath: will then reflect these new rows).
If you are also wanting to wait until the user scrolls to the end of the current list before continuing the query, note that UITableView is a subclass of UIScrollView and UITableViewDelegate implements UIScrollViewDelegate. So just use scrollViewDidScroll: on your UITableViewDelegate to know when the user scrolls and then check the table view's contentOffset to determine if they've scrolled down far enough that you want to load more data.
whats the average number of items people can have? 10, 100, 1000? Does it have images or just data? Generally, I'd vote for not having any pagination - just load more as you scroll down, and try to load all of them at the very first time if there are not too many. You can also cache them on the device and add "pull to refresh" functionality, this way you improve offline experience.
Well if some one is interested in paging using buttons then I found this post usefull http://www.mindyourcode.com/ios/iphone/pagination-in-uitableview-with-next-previous-buttons/
may be for some others it would be helpful
I want to have a screen in my app that shows real-time log information - e.g. a scrolling list of textual strings. Previously I've seen people just use a textview and append new log entries to the list - it seems this may be not so efficient, especially when the list becomes long. Is there any sample code out there that can efficiently show real-time text log information? Or does everyone just write their own using a tableview?
Thanks
UITableView would be the way to go here, and using the deque idea Alex mentioned above, just call insertRowsAtIndexPaths:withRowAnimation: and deleteRowsAtIndexPaths:withRowAnimation: as you push/pop log entries onto your deque.
If you're building your own, perhaps you could use a deque of UITextView instances, adding to the end of the queue and removing from the front, only buffering a constant number of instances.
You could perhaps feed the deque to a UIView that contains the text views as subviews, with various offsets set based on how many lines your application is displaying at one time.
In reference to my previous question, I would like to know how to implement a large grid of cells in an iPhone application.
I'm working on an interface which would be similar to an Excel spreadsheet, with many rows and columns. Do I have to handle each cell separately? How can I handle user interaction in each cell?
Is there a standard way to create this type of control?
There is no real standard mechanism.
If all of the cells in a given row will always fit in the width of the screen, one way to do it would be to create a UITableViewCell with several UILabels and vertical separators between them. If all of these rows had "columns" of the same width, you would get the appearance of a grid.
If that isn't possible, it might be helpful to think about what the table view control truly is. A table view is just a scroll view that automatically adds, removes, and recycles its subviews so that only the ones that are visible at a given time are in memory. There is no reason you could not write a GridView control that did the same thing, but in two dimensions. It wouldn't be as easy as using the built-in table view, of course, but if the table view can't do what you need, well, that's why Apple isn't writing all the apps.
Sounds like the exact thing that UICollectionView was made for!
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html
Look at my answer to this question: MS Excel type spreadsheet creation using objective-c for iOS app.
Basically there's no standard way to do this. You will need to made everything by hand and there's 3 ways to go:
Use a UIWebView and layout everything using html/js.
Modify a UICollectionView.
Make everything by hand using Core Data.