How detect indexPath on click button at row? - objective-c

I have this UItableView:
I would like to increment/decrement the concrete UIProgressView at row, when I clicked on minus/plus and than also reload, whole UITableView, because all rows are interdependent. I don't how detect on which row was pressed the minus/plus UIButton. I tried to use rowDidSelect, but it didn't work. Could you please advise me please?
EDITED
I have a class for UITableCell (ActivityCell - class) and class for UITableViewController (lessonActivityTVC - class). At class of Cell I have IBOutlets.
ActivityCell.h
#interface ActivityCell : UITableViewCell
#property (strong, nonatomic) IBOutlet UILabel *studentNameLabel;
#property (strong, nonatomic) IBOutlet UIProgressView *progressView;
In ActivityCell.m I have nothing new. I had here a IBActions for buttons, but I moved the actions into lessonActivity.m because, when I press any button I need reload the UITableView and I didnt know how do it in ActivityCell.m. My code of lessonActivityTVC.m is here:
#implementation tchLessonActivityTVC
#define debug 1
- (IBAction)incrementActivity:(id)sender {
NSLog(#"increment");
}
- (IBAction)decrementActivity:(id)sender {
NSLog(#"decrement");
}
-(void)fetchData{
CoreDataHelper *cdh = [(AppDelegate*)[[UIApplication sharedApplication]delegate]cdh];
SchoolClass *schoolClass = (SchoolClass*)[cdh.context existingObjectWithID:[IDsManager getClassID] error:nil];
Lesson *lesson = (Lesson*)[cdh.context existingObjectWithID:[IDsManager getLessonID] error:nil];
if (lesson.activities.count == 0) {
for (Student *student in schoolClass.students) {
Activity *activity = [NSEntityDescription insertNewObjectForEntityForName:#"Activity" inManagedObjectContext:cdh.context];
activity.student = student;
activity.lesson = lesson;
[lesson addActivitiesObject:activity];
[student addActivitiesObject:activity];
}
}
self.activities = [NSArray arrayWithArray:[lesson.activities allObjects]];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.delegate = self;
[self fetchData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.activities.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(debug == 1){
NSLog(#"Running %# '%#'",self.class, NSStringFromSelector(_cmd));
}
static NSString *cellIndetifier = #"Activity Cell";
ActivityCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndetifier
forIndexPath:indexPath];
Activity *activity = [self.activities objectAtIndex:indexPath.row];
cell.studentNameLabel.text = activity.student.name;
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 5.0f);
cell.progressView.transform = transform;
cell.progressView.progress = 0.32f;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"selected index is %d",indexPath.row);
}
#end

UITableView has a delegate method didSelectRowAtIndexPath: and you get the indexPath.row from there. Don't forget to set your class as a UITableViewDelegate by adding <UITableViewDelegate> on the end of #interface line and setting
tableView.delegate = self;
in code, or do it in Interface Builder. If you are on UITableViewController, you get this for free.
Edit:
Here is the delegate pattern example:
tableviewcell h
#protocol TableViewCellDelegate <NSObject>
- (void)requestToReloadTableViewFromCell:(UITableViewCell *)cell;
#end
#interface TableViewCell : UITableViewCell
#property (weak, nonatomic) IBOutlet UILabel *dateLabel;
#property (weak, nonatomic) id <TableViewCellDelegate> cellDelegate;
#end
tableviewcell m
- (IBAction)buttonAction:(UIButton *)sender
{
[self.cellDelegate requestToReloadTableViewFromCell:self];
}
tableviewcontroller m
#interface TableViewController () <TableViewCellDelegate>
#end
#implementation TableViewController
- (void)requestToReloadTableViewFromCell:(UITableViewCell *)cell
{
NSLog(#"%d", [[self.tableView indexPathForCell:cell] row]);
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cell" forIndexPath:indexPath];
// Configure the cell...
cell.cellDelegate = self;
cell.dateLabel.text = [[NSDate date] description];
return cell;
}

you can use the tag with these buttons programatically in cellForRowAtIndexPath method. Tag should be different for each button (you can use some formula, for example tag will be equal to row no). in this way when button will be pressed you will check tag first and can know which button is pressed at which row.

Related

TableView does not update when I pass a string from another view

I want to populate a UITableView by passing a string from a UIViewController to a UITableView.
This is my code so far:
UITableViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
NSMArray = [[NSMutableArray alloc]initWithObjects:#"text",#"text2", nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return NSMArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier ];
}
cell.textLabel.text = [NSMArray objectAtIndex:indexPath.row];
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove fron NSMutableArray
[NSMArray removeObjectAtIndex:indexPath.row];
//delete from table
[tableView deleteRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationTop];
}
}
-(void)getString:(NSString *)string
{
if ([make length] > 0) {
if (!NSMArray)
{
NSMArray = [[NSMutableArray alloc]init];
}
[NSMArray insertObject:make atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.myTableView insertRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
UITableViewController.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
#property (strong, nonatomic) IBOutlet UITableView *myTableView;
#property (strong, nonatomic) NSMutableArray *NSMArray;
-(void)getString:(NSString *)string;
ViewController.m
#import "entryViewController.h"
#interface entryViewController ()
#end
#implementation entryViewController
#synthesize textfieldString, myString;
- (void)viewDidLoad
{
[super viewDidLoad];
//Save button
UIBarButtonItem *SaveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:#selector(pushCarMake:)];
self.navigationItem.rightBarButtonItem = SaveButton;
}
- (void)pushCarMake:(id)sender
{
myString = textfieldString.text;
ViewController *mainVC = [[ViewController alloc]init];
[mainVC getString:myString];
//pop to root ViewController
[self.navigationController popToRootViewControllerAnimated:TRUE];
}
#end
ViewCotroller.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#interface entryViewController : UIViewController
#property (strong, nonatomic) NSString *carMake;
#property (strong, nonatomic) IBOutlet UITextField *textfieldCarMake;
So this works fine and populates the Table View with the string items instantiated in the viewDidLoad of the UITableViewCotroller. But every time I pass a string from the ViewControllers to the table View it does not go into the table. any suggestions why this is. Sorry for pasting so much code.
One approach for passing data from a detail view controller back to it's parent is using a delegate. Here's an example:
How do I set up a simple delegate to communicate between two view controllers?
[Edited]
The other approach if you're using storyboards is to use an unwind segue. Here's a sample I put together using this approach: github.com/soleares/AddToTableView
Not positive if this is the only issue, but try adding beginUpdates and endUpdate
[myTableView beginUpdates];
[self.myTableView insertRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[myTableView endUpdates];

Trying to call a second table view with the items of de selected playlist in the first view

Maybe there's someone outthere who can help me fiure out my problem. I cant seem to display the playlistItems using cocoalibspotify. I have set up my playlistview and the first ableviewcontroller shows the playlist but when i try to call the items of the selected playlist I seem to get 0 numbersof row as my outputs show. the first view show how i pass the indexpath to the secondviewcontroller. the second script show my .h and .m files of the playlistitemsTavle view controller.
Overview.m - tableView with Playlists
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[playlistView deselectRowAtIndexPath:indexPath animated:NO];
playlistItemViewController *trailsController = [[playlistItemViewController alloc] initWithStyle:UITableViewStylePlain];
trailsController.currentPlaylist = [playlistArray objectAtIndex:indexPath.row];
//[[self navigationController] pushViewController:trailsController animated:YES];
[self getSongs];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showPlaylistItem"]) {
UITableViewCell *BasicCell = (UITableViewCell *) sender;
NSIndexPath *ip = [self.tableView indexPathForCell:BasicCell];
SPPlaylist *selectedPlaylist = [playlistArray objectAtIndex:ip.row];
playlistItemViewController *pivc = (playlistItemViewController *) segue.destinationViewController;
pivc.currentPlaylist = selectedPlaylist;
}
}
playlistitemsViewController.h -
#import <UIKit/UIKit.h>
#import "CocoaLibSpotify.h"
#import "Simple_PlayerAppDelegate.h"
#import "overViewController.h"
#interface playlistItemViewController : UITableViewController
{
UITableView *tableView;
}
#property (retain, nonatomic) IBOutlet UITableView *tableView;
#property (strong, readwrite, nonatomic) SPPlaylist *currentPlaylist;
#end
playlistViewController.m - this should call the playlist items
#import "playlistItemViewController.h"
#interface playlistItemViewController ()
#end
#implementation playlistItemViewController {
}
#synthesize currentPlaylist;
#synthesize tableView;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
NSLog(#"numberOfRowsInSection: %d",[[currentPlaylist items] count]);
return [[currentPlaylist items] count];
}
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"SubtitleCell";
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [[[currentPlaylist items] objectAtIndex:indexPath.row] valueForKey:#"name"];
return cell;
if (indexPath.row == 0) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"SubtitleCell"];
[[cell.backgroundView superview] bringSubviewToFront:cell.backgroundView];
cell.textLabel.text = #"";
}
else{
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"SubtitleCell"];
}
SPPlaylistItem * item = [[currentPlaylist items] objectAtIndex:[[currentPlaylist items]count] - indexPath.row];
cell.textLabel.text = [item.item name];
if (item.itemClass == [SPTrack class]) {
SPTrack * track = item.item;
cell.detailTextLabel.text = [track consolidatedArtists];
}
}
return cell;
}
#end
You need to wait for the playlist to load before the items are available.
Your playlist view controller needs to use SPAsyncLoading to load the playlist, something list this:
[SPAsyncLoading waitUntilLoaded:self.currentPlaylist timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedItems, NSArray *notloadedItems) {
[self.tableView reloadData];
}];
Playlist loading can take a while, so make sure you put up some "loading" UI. You'll also need to load the visible tracks in a similar manner before their names will be available.

Adding UITableView to existing UIViewController

I have a UIViewController which open up a Camera, after doing the imagePickerController:didFinishPickingMediaWithInfo: a UITableView shall be shown.
Somehow the tableView delegation code is not triggered. A tableView is shown on my iPhone but with empty rows. Seems that just the IB Stuff is displayed without the code. But I cannot figure out what I missed.
How do I get the UITableView working?
MainStoryboard.storyboard
Camera View Controller Scene
----------------------------
Camera View Controller
View
Image View // hooked up with .h
Table View // hooked up with .h
Table View Cell - clocation
CameraViewController.h
#import <UIKit/UIKit.h>
#interface CameraViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITableViewDataSource, UITableViewDelegate>
#property (weak, nonatomic) IBOutlet UIImageView *imageView; // hooked up with IB UIImageView
#property (strong, nonatomic) NSMutableArray *locations;
#property (strong, nonatomic) IBOutlet UITableView *tableView; // hooked up with IB UITableView
#end
CameraViewController.m (Updated 20130725 with working solution)
#import "CameraViewController.h"
#interface CameraViewController ()
#end
#implementation CameraViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// self.locations = [[NSMutableArray alloc] init];
// is filled with content when photo is taken. Means has content when tableview shall be shown.
self.locations = #[ #"foo", #"bar" ]; // dummy setup for this thread
// Do any additional setup after loading the view.
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
// select Photo
} else {
[self takePhoto];
}
[self initTableView];
}
// [...] Camera Stuff
#pragma mark - table view things
-(void)initTableView {
_tableView.dataSource = self;
_tableView.delegate = self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.locations.count; // a breakpoint is configured but never get hit...
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"clocation";
// Not working in this case:
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// You have to use this one:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:#"Empty Cell %d", indexPath.row];
return cell;
}

Passing data back :Delegate method not called

I am working on an app that connects with google docs using oauth 2.0, once the user has connected, He clicks a button that goes to a tableView to show all the documents. For this I am using a segue and passing data forward. Now I want the user to select one document, put a checkmark on it and return to the viewcontroller passing data back and display wich document was selected. I read that for passing data back I needed to use a protocol and a delegate. I followed this: Passing Data between View Controllers but my problem is that my delegate method is not being called.
Here is my storyboard, just 2 views, a viewcontroller and a tablaviewvcontroller called VistaTableViewController.
When the user pushes the authenticate button, He connects with google docs using oauth. When he pushes the "Listar" button the VistaTableViewController appears.
Here is the code of VistaTableViewController.h where a define the protocol:
#import <UIKit/UIKit.h>
#import "GData.h"
#class VistaTableViewController;
#protocol VistaTableViewControllerDelegate <NSObject>
- (void)loqueselecciono:(VistaTableViewController *)controller didSelectDoc:(NSString *)documento;
#end
#interface VistaTableViewController : UITableViewController <UITableViewDataSource>
{
IBOutlet UITableView *tablalistar;
GDataFeedDocList *mDocListFeed2;
}
#property (nonatomic, weak) id <VistaTableViewControllerDelegate> delegate;
#property (nonatomic, strong) NSString *documento;
#property (nonatomic, retain) GDataFeedDocList *mDocListFeed2;
#end
Here is the code of VistaTableViewController.m where I call the delegate method:
#import "VistaTableViewController.h"
#implementation VistaTableViewController
{
NSInteger selectedIndex;
}
#synthesize delegate;
#synthesize documento;
#synthesize mDocListFeed2;
- (void)viewDidLoad
{
[super viewDidLoad];
selectedIndex = [[mDocListFeed2 entries] indexOfObject:self.documento];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[mDocListFeed2 entries] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"tablalistar"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"tablalistar"];
}
GDataEntrySpreadsheet *doc = [[mDocListFeed2 entries] objectAtIndex:indexPath.row];
cell.textLabel.text = [[doc title] stringValue];
if (indexPath.row == selectedIndex)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (selectedIndex != NSNotFound)
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:selectedIndex inSection:0]];
cell.accessoryType = UITableViewCellAccessoryNone;
}
selectedIndex = indexPath.row;
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
GDataEntrySpreadsheet *doc = [[mDocListFeed2 entries] objectAtIndex:indexPath.row];
NSString *theDoc = [[doc title] stringValue];
[self.delegate loqueselecciono:self didSelectDoc:theDoc];
}
#end
Ok, so now I just need to tell ViewController to import VistaTableViewController and conform to its protocol.
here is the code of ViewController.h
#import <UIKit/UIKit.h>
#import "GTMOAuth2ViewControllerTouch.h"
#import "GData.h"
#import "VistaTableViewController.h"
#interface ViewController : UIViewController <VistaTableViewControllerDelegate>
- (GDataServiceGoogleDocs *)docsService;
- (void)authorize;
- (void) mifetch;
- (IBAction)autenticarse;
- (IBAction)listar:(id)sender;
- (void) ticket: (GDataServiceTicket *) ticket finishedWithFeed: (GDataFeedDocList *) feed error: (NSError *) error;
#property (nonatomic, retain) NSString *accessToken;
#property (nonatomic, retain) GDataFeedDocList *mDocListFeed;
#property (nonatomic, retain) GDataServiceTicket *mDoclistFetchTicket;
#end
Then in Viewcontroller.m I implement the delegate method as follows: (I just want to display an alert showing the title of de document that was selected).
- (void)loqueselecciono:(VistaTableViewController *)controller didSelectDoc:(NSString *)documento;
{
[self.navigationController popViewControllerAnimated:YES];
UIAlertView *alertView = [ [UIAlertView alloc] initWithTitle:#"doc seleccionado"
message:[NSString stringWithFormat:#"titulo: %#", documento]
delegate:self
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[alertView show];
}
and in Viewcontroller.m as well I wrote this to assign self to the delegate.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:#"displaydocs"])
{
VistaTableViewController *vistatableview = [[VistaTableViewController alloc] init];
vistatableview.delegate = self;
vistatableview = [segue.destinationViewController performSelector:#selector(setMDocListFeed2:) withObject:mDocListFeed];
}
}
Ok, so I get de tableView displaying all the documents and the user can select one showing de checkmark but the delegate method is not being called so It does not return to the viewcontroller view and no data is passed back.
What am I missing?? Thanks!!
When you write VistaTableViewController *vistatableview = [[VistaTableViewController alloc] init]; you are creating a new object. What you really want to do is use the segue.destinationViewController, which should be a VistaTableViewController and set its delegate to self.
As is, the object with the delegate is not the object being pushed and handling the view logic.
(Also, setMDocListFeed2 doesn't return an object so the assignment on performSelector is rather misleading.)

Table View Controller and TextField Inside ModalView

I try to add tableView and TextField inside the ModalView. I do so. I create new View Controller and give for it
#import <UIKit/UIKit.h>
#protocol UYLModalViewControllerDelegate
-(void) buttonDonePassed :(NSArray *) variables;
#end
#interface UYLModalViewController : UIViewController <UITableViewDelegate>
{
id<UYLModalViewControllerDelegate> delegate;
IBOutlet UITableView *tblView;
IBOutlet UITextField *textField;
NSMutableArray *cellsArray;
//UITextField *textField;
}
#property (nonatomic, assign) id<UYLModalViewControllerDelegate> delegate;
#property (nonatomic, retain) IBOutlet UITableView *tblView;
#property (retain, nonatomic) IBOutlet UITextField *textField;
#end
And IN .m File I create functions
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [cellsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [cellsArray objectAtIndex:indexPath.row];
// Configure the cell.
return cell;
}
and ViewDidiLoad
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(buttonPassed:)];
//UITableView *tableView = [[UITableView alloc] init];
//[self]
cellsArray = [[NSMutableArray alloc] initWithObjects:#"one",#"two",#"three", nil];
[tblView reloadData];
}
But my program don't go to the TableViewDelegate methods (such as cellforrowAtIndexPath)
You need to set your UYLModalViewController as the tableView's delegate and datasource.
It looks like you are using Interface Builder so you need to:
control + click on the tableView and drag it across to the File's Owner
Then select datasource from the HUD menu.
Then repeat the process but selecting delegate
Note
Your controller should also conform to UITableViewDatasource giving you:
#interface UYLModalViewController : UIViewController <UITableViewDelegate, UITableViewDatasource>
1.
2.
If you prefer you can do this in code in viewDidLoad or any place where you create the tableView if you do it programatically.
self.tableView.delegate = self;
self.tableView.datasource = self;