I'm working on an iOS project, writing in Swift. It's a social network app where people have profiles and they can post different type of content. There should be 9 type of posts/content:
Normal (text only) post
Images post
Gif post
Video post
Audio post
Quote post
Chat post
Poll post
Link post
My question is related to how should I display it on the feed. The feed obviously would be some type of a collection (I think I'll stick with UICollectionView) but should I create 1 type of a cell, add every single element that I might need to display each type of a content embedded into a UIStackView and if it's the database request returns nil for an object (i.e that particular post doesn't have video or an audio, a poll, etc - all it contains is just some images) then I'll hide those UIStackViews from the cell OR should I create a separate type of a cell and its xib file, depending on the the content type?
I feel like the latter would be easier, but I'm not how to that? Meaning, how should I check what type of a content is it? Imagine something like Twitter for example, you see many different type of content, how should you approach the cell creation and displaying them?
PS: Keep in mind that the users should be able to filter their content based on the content type (i.e display only images, only text, only audio, etc). How should I approach this?
IMHO, it is better to create separate cell for every content type and manipulate views in it as needed. It is clearer and simpler solution.
Better option is create the different cell for different posts/content, and use the model classes variable/enum for know which type of content is it. its easy for filtering and managing the all type of posts.
Related
I am very new to swift and currently making an app for a school project. The app is supposed to show a collection of recipes. I have begun by having a scrolling grid of buttons (stackviews and scrollviews). Each recipe is supposed to connect to a specific recipe, and when clicked segue to a view that has the information for the recipe (image, ingredients, instructions, etc.). I would like to do this by creating a a basic recipe view file that has a space for an image, title, and text. Then, depending on what button was pressed, fill in the view with the correct information and display the view.
I have figured out an alternative method that I could use, but it is very bulky and tedious. I could set up views for the ~25 different recipes separately, and link them individually to each button.
I would much rather prefer the first option, but I am not quite sure if it is even possible, or if I am just really bad at using the right search terms in google. I know many other apps have similar systems set up, for example a social media profile is the same template for everyone, just has different data displayed inside of it.
Can anyone help me out? Thanks in advance.
You can use UITableView for this task and have a model array that you fill with the required data ,and for action use didSelectRowAt to find which cell is clicked send the data to the next VC
I want to create an app for a news agency. The app has to display long articles with images/yotube videos like the news agencies website.
The article will come in json format from the api.
What is the best ways to do this so that the app looks and feels like the website.
NOTE: Cant use webViews so the options left are UITextField,UITextView for article inside a Table View or Scroll View?
What would be the best implementation?
Example URL For Article
I would use a UITableView or a UICollectionView.
I second dasdom......so that the view doesn't get boring (ie. the same style of cell all the way through) create 2-3 different reusable cells and call these to display different media.
I would suggest Use a Table view with show more and show less article content functionality with some kind of animation can be the best implementation for this.
So I want users to be able to enter a search query, and should it return an empty or non-empty result the appropriate view is displayed (shown below):
As I'm fairly new to iOS I thought about the following possible ways of implementing this. I'm not sure if any one of these is deemed as good practice or maybe another better solution exists:
Create two separate view controllers with their own views that will display a message for empty search results or show non-empty results respectively
Create a single view that will house all of the components and show/hide certain components based on whether or not the results are empty/non-empty
Create a single view, but programmatically implement the methods for drawing the relevant components and just initialise the VC with the respective designated initializer (one for empty and the other for non-empty results)
The best practice is to manage the empty state of tableview meaning have a single tableview and display data when available, if no data is available display a friendly message in the tableview itself.
Below is the link that will help you implement the code:
http://www.ryanwright.me/cookbook/ios/objc/uitableview/empy-table-message
There are ots of examples available on net for managing the empty state of tableview.
I'm new to iOS development. I have finished the "console" part of my app (it does what I need it to do in a Mac app without a UI), but now I have no idea on where to start for my (iOS) UI part.
Basically, I need something like a simple grid of cells (like Excel); my code reads a file, creates a dynamic (varies per file content) 2D array, and I want to show this on my UI, making each cell selectable by the user (each cell would correspond to a position in my 2D array).
Could someone point me in the right direction (even if its only the name of the classes I need to look up in apple's doc.)? I have been trying to find answers online, but it seems I'm not looking for it right.
In case I didn't explain myself correctly, I want something like this:
UICollectionView is the correct class to use for this. It allows you to create layouts with multiple rows and columns in a similar style to UITableView. You can also create your own custom layouts if the default one does not do what you need.
What is the best way to display some text data as output in an iphone application.
I am able retrieve a set of details about a particular car in my application.How to display them in a nice way.Currently i am using Labels.
Is there any better way.. I am new to ios programming
It really depends on the structure of the text data that you want to show.
For plain text, a UILabel is good. You can set the numberOfLines property if you want to show more than one line, or unlimited number of lines (set to 0).
For rich text, you can use a UITextView.
For HTML, UIWebView gives you Safari's rendering behavior and support.
For one-column tabular data, the classical UITableView is good. It's best for hierarchical information, that is, it is appropriate for when you have to present the user a bunch of records (maybe retrieved from some database) and you group them by some criteria (sections, or "group by" in SQL terminology). Each of those records may have additional information that you show when the user taps on the corresponding table view cell.
If you want to show multi-column tabular data, or any other complex layout that UITableView does not support, you can use a UICollectionView (available from iOS6+).
You can use UITableView Custom Cell with UILabels and UIImages for cars, please refer WWDC 2013 videos Building User interfaces for iOS7 and Best practices for great iOS UI Design https://developer.apple.com/wwdc/videos/ for reference and http://pttrns.com/categories/20-content-screen
You can use UITableView, with custom cells for car image and other details.
Table View is best options for you.
Create a UITableView And add an UIImageView and UILabel for details of car....