still learning iOS development, want to create something like mention friend likes in Facebook / Instagram.
Mention People UI in Instagram
Is it using new TableViewController and add subview to the same View Controller? (in this case, CommentViewController) , but, when i already have UITAbleViewController in my CommentViewController, how can i handle the second tableviewcontroller?
Looking at the image you provided it looks as though the best way to implement this would be a UIViewController that has a UITableView added to it. Each tableview that is created can have a delegate and datasource set for it. When the textview detects that a mention is being entered (more about detecting this later) you would trigger a second tableview to appear as an additional view (subview) that overlays your current tableview (or as the accessory view of the keyboard, the way apple and others present a textview over the keyboard for text entry ex: messages app).
In order to manage the two tableviews my suggestion would be to create two additional classes each of which conform to the UITableViewDelegate and UITableViewData source. The first one would be the CommentsTableViewManager and the second would be the MentionsTableViewManager. The first tableview would set the CommentsTableViewManager as its delegate and datasource while the second would use the MentionsTableViewManager.
The other problem you may run into later on is determining how to properly detect mentions being typed into the textview. I've actually created an open source library that will help you with this problem. It's located here: https://github.com/szweier/SZMentionsSwift the README should provide enough information for you to get started if you choose to use it.
I hope the information about helps get you started with your app.
From architecture prospective it's way better to have a single table view with altered data source container, depending on current mode.
Speaking an instagram way - either you're showing comments, or, if # symbol was detected, displaying a list of users. So almost all your UITableView's delegate and data source methods will start with something like if (isMentionMode) and you'll choose specific cell class/cell's height/amount of rows per section/etc depends on isMentionMode state.
Related
I just finished going through a few books on iOS developing and starting my first app. I was wondering if anyone knew of a cheat sheet (or just a list) that shows the various views (e.g., table view, collection view). I'd like something that has the view/controller and an image of what it looks like and a few examples when/how to use it.
I've done multiple Google searches and reviewed Apple's docs but can't seem to find just a list of the various ones that are available.
Here's a blog post with code that uses a for loop to traverse the class and print out all of its children. Shows you basically every child of the UIView class.
List of Every UIView Subclass
Also, here's a reference to some Apple docs:
View Controller Basics
UIView Controller class (most other views should be children of this class)
Start Xcode, open a XIB or Storyboard, look at the bottom right where you'll find the palette.
Alternatively there's a sample project called UICatalog that shows most of the available views/controls.
Im new to IOS developing and i would like, as one of my start projects to learn more about table views. I would like to fill a table view up and then be able to handle clicks on them, to open a webpage etc. Does someone know a good tutorial or code for this?
Thanks!
What you want is the UITableViewDelegate documentation.
Specifically, tableView:didSelectRowAtIndexPath:. You can then lookup the cell at the given indexPath and handle it accordingly. More info on delegation can be found in the docs if you need it, but you'll want to implement methods like that in the object referenced as the delegate of your tableView
Is it more appropriate to have one shared instance of and iAd for my app or can I create a new instance on each page of a navigation app? It seems Apple's sample code has only one ad that is used one each page. From my perspective more ads means more money. Is there an issue doing it in this manner or am I looking at this incorrectly?
Creating a new instance for every page would be standard. It is non-standard and to try to use the same instance across different pages. (To do that you'd need to remove the ADBannerView from its superview and then add it as a subview of the next view.)
My guess is that the amount of money you'd receive would be approximately the same either way. If you could get more money one way or the other it would be a bug that Apple would fix.
I think honestly you can do it either way. I have an app that is a paged scroll view that has an ADBannerView just off screen (below). When an add gets loaded the scroll view shortens by the height of the ADBannerView and the AdBannerView gets moved up. Its the same object for each page of the UIScrollView.
Some might argue though that my app is really only 1 view, since each 'page' is part of the same ScrollView.
According to the Apple sample code, you should use one instance. If you download the iAdSuite samples, you'll see this in the ReadMe.txt file:
Note: If your application has multiple tabs or views displaying an iAd
banner, be sure to share a single instance of ADBannerView across each
view. Then, before your users navigate to a new view, set the shared
instance's delegate property to nil, remove it from the old view
hierarchy, then add the same instance to the opening view and set its
delegate to the appropriate view controller.
Apple encourages you to use one instance of iAd Banner per app as a best practice. You can read the following technical note for how and why:
http://developer.apple.com/library/ios/#technotes/tn2286/_index.html
So, am attempting to use one AdBannerView for my two views in an application I am building. The views consist of a main view that shows data, and an editing view that allows the user to edit the data. I would like the banner to display on both views as appropriate (i.e. when they are viewing data or editing data).
I have attempted to follow the tutorial that Apple provides, specifically the iAdSuite tutorial, using the AdBannerNavigation tutorial as an example. The problem is that they base all of their event structure - i.e. when they add and remove the banner from the views, and set themselves as the delegate of the banner - on when the views load and unload. Since my main view never unloads (as it is controlling large portions of the data), how can I have it pay attention to events to follow this simlar behavior? Should it be on viewWillAppear/viewWillDisappear? Or on the "did" version of both of those? Or is there some other event that I am missing that I should pay attention to?
So, after banging my head against the wall some more, I figured out a few things.
What I did was make it work on the viewDidAppear and viewWillDisappear methods for both UIs. I also found that my bindings (struts?) for the view pieces in the interface builder were not correctly set up - I had to fix those so that the items were willing to contract in a vertical direction.
I'm currently learning ObjC and Cocoa programming, coming from the Java world.
To test my current skills and learning progress I'm creating a small calculator app from scratch (OSX not iOS).
My UI has 10 digit buttons 0-9 among others.
My first thought was, since the action receives the senders reference, to make one action
like -(IBAction)captureDigit:(id)sender and then just grab the digit from the button title.
But the interface builder only allows an action to be connected with one sender it seems.
So I ended up creating 10 captureDigit actions in my controller.
My Question:
is the first option possible somehow? I thought of adding the actions programmatically (is this possible?) to the buttons, but then I would have to add all digit buttons as outlets to my controller.
Bonus Question:
can a NSButton hold some kind of non visible value? Could not find this in the documentation.
Maybe this would violate the MVC pattern as the UI would then know of application specific data?
Thanks for any useful and kind answer in advance, I'm still learning
You can connect many senders to one target/action if you Control-drag from senders to the target, so that's not a problem.
WRT your bonus question, any NSView has an integer tag which you can set in Interface Builder. That's a convenient way to differentiate multiple similar views.
You can definitely connect more than more button to a single action. Also, you can use the tag field of any object to give it a "behind the scenes" value.
It's perfectly possible to add as many actions to a single controller. How is Interface Builder preventing you from doing this?
You could have a NSDictionary instance in your controller, in which you could match NSButtons to whatever data you want.
To make it easy, in IB create one button and drag from NSButton to File's owner it then shows all of the methods that we can send to NSButton, then select captureDigit:. Now copy and paste the button change the title, copy and paste in IB keeps the connection and use tag field as costique, nitrex have already said.