Handle clicks in table view cell - objective-c

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

Related

Pass data from Collection View to Table view

I am a new learner, I am doing an assignment, stuck on this point. My target is when user click on a cell inside collection view, I have to go on table view and pass data to it (Which means that table view will have only one cell with data for selected collection view item).
I know I will go to table view programatically not possible through storyboard(If possible let me know) by using delegate method didSelectItemAtIndexPath
Can you explain the way to open table view from collection view cell click and how I will wrap data to pass to other controller (I think Segue? But how if we cannot use storyBoard). I am not getting clear there is no much help on internet in objective c? If you provide some pathway it will be good and if you explain it would be excellent??? Any helping material will be a plus
I am using XCode11 with objective c and not using XIB files Just working by storyboards
I also think segues is the way to solve your problem.
Set up the segue in storyboard and then inside the didSelectItemAtIndexPath set some variable with the data you want to pass and use performSegueWithIdentifier:sender to kick off the segue. Then override prepareForSegue:sender to transfer this data to the destinationViewController. You could use the sender to transfer the data from perform... to prepare... as well but I suggest for now just use some instance variable.

Create a Mention friend in iOS with Objective-C

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.

Working with multiple NSTableView into NSWindowController?

I am working to a window with multiples NSTableView (in my case 8) and I am not sure if it's correct what I do.
My screen look like printscreen : custom window
In principle my window it's a Master - Detail Interface a selection of table from the left must populate the right table.
Until now I succeded to populate all the tables from the left with help of cocoa binding - NSArrayController which contain custom objects but further I don't know how continue, obvious in my mind it's to implement delegate method for NSTableView: tableViewSelectionDidChange:notification but this require more glue code.
My question if it's possible to populate the right table with help of cocoa binding without glue code. I read documention and I tried with selection proprety of NSArrayController but all my attempts failed. Any suggestion?

Using Custom Cell for Mac Application

Does anyone have any info on this? I'm new to cocoa, all tutorials seem to be for iPhone which uses a different view controller. Anyone willing to provide a step by step for adding labels to a custom cell? (I'm pulling from Core Data)
EDIT: It's important to note I'm using Core Data here. Many tutorials use arrays.. I don't understand why you would use that??
I'll award an answer quickly!
Zach
I'm not sure if this is going to help you, but your problem seems unrelated to your use of CoreData.
If I've understood your problem correctly, here are some steps:
Populate your NSTableView
Using CoreData, what you can do is put an NSArrayController object in your XIB document, set its mode to Entity and choose the Entity you want to display in your TableView (all of this from the first tab of the inspector on your array controller object).
Then, bind your NSTableView Content to the arrangedObjects of the array controller. You might also bind the selectionIndexes and use some sort descriptors on the array controller to order your data, as CoreData will give you a set rather than an array.
Click on your table view as many times as necessary as to select the table column in which you want your custom cell to appear, and set its Value binding to arrangedObjects too.
Set your custom cell
Finally, click on the cell of this table column and in the "Identity" of the inspector, change the class name of the cell to the class name of your custom cell.
I'll let you read the appropriate documentation to implement your custom cell according to what you want to achieve.
With the different bindings I've described, the objectValue of your cell should be the object from your array controller at the same index of the row your cell will appear on.
Please note that I've not tested again all of these steps but answered from memory... there might be details I've missed but you should have the main steps here.

Using a UIPickerView with custom values

Im using a navigation controller and a normal view. In the view I'd like a UIPickerView with custom values in it. It would have one column with about 15 values in it. And I want the ability to add an action to each value.
Is there any way I can do this using Xcode? I can't seem to find the corrent help.
Cheers.
You need to look at the documentation for UIPickerViewDelegate.
In order to have an action for each value you will implement pickerView:didSelectRow:inComponent: and have a different action based on which row was selected.
For the contents of the rows you can implement pickerView:titleForRow:forComponent: if your contents are simple text.
If you want custom drawn contents you can provide a custom view for each row with the pickerView:viewForRow:forComponent:reusingView: method.
See the UICatalog example that is available in the iPhone Developer examples.