HelloI'm very new to Objective-c development and i will like to know if there is a sample code that uses TableView when the video is clicked on it loads the youtube video.Currently im able to load the list on the iPhone but when click, it only highlights but nothing else happens.Is there a sample code somewhere that solves this problem or is there a solution that I need to add to my code?Thank you in advancenewBThis is my ViewController.h file#import <UIKit/UIKit.h>
#import "MainViewModel.h"
@interface ViewController : UIViewController<MainViewModelDelegate, UITableViewDelegate, UITableViewDataSource>
{
MainViewModel *modal;
UITableView *tblVideos;
}
@end
This is my ViewController.M--#import "ViewController.h"
@implementation ViewController
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
modal=[[MainViewModel alloc] init];
modal.delegate=self;
tblVideos=[[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
[tblVideos setDelegate:self];
[tblVideos setDataSource:self];
[self.view addSubview:tblVideos];
}
- (void)viewDidUnload
{
[super viewDidUnload];
modal=nil;
tblVideos=nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
#pragma ModalViewDelegate
-(void) DataLoadingFinished
{
[tblVideos reloadData];
}
#pragma UITableView Datasource methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [modal.Videos count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier=@"YoutubeVideosCell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if(!cell)
{
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
YoutubeItem *currentItem=[modal.Videos objectAtIndex:indexPath.row];
[cell.textLabel setText:currentItem.title];
[cell.imageView setImage:currentItem.thumbnail];
return cell;
}@end
You received this message because you are subscribed to the Google Groups "iPhone Application Development Auditors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iphone-appdev-aud...@googlegroups.com.
To post to this group, send email to iphone-appd...@googlegroups.com.
Visit this group at http://groups.google.com/group/iphone-appdev-auditors?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
}
@end
To unsubscribe from this group and stop receiving emails from it, send an email to iphone-appdev-auditors+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to iphone-appdev-auditors+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to iphone-appdev-aud...@googlegroups.com.
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
YoutubeItem *currentItem=[modal.Videos objectAtIndex:indexPath.row];
NSString* msg = [NSString stringWithFormat:@"You Selected the Youtube Video, %@ [id: %@]", currentItem.title, currentItem.itemId];
UIAlertView* av = [[UIAlertView alloc] initWithTitle:@"didSelectRowAtIndexPath"
message:msg
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[av show];
}
Best
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
YoutubeItem *currentItem=[modal.Videos objectAtIndex:indexPath.row];
NSString* msg = [NSString stringWithFormat:@"You Selected the Youtube Video, %@ [id: %@]", currentItem.title, currentItem.itemId];
UIAlertView* av = [[UIAlertView alloc] initWithTitle:@"didSelectRowAtIndexPath"
message:msg
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[av show];
// webView is a UIWebView, either initialized programmatically or loaded as part of a xib.
NSString *htmlString = @"<html><head>
<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>
<body style=\"background:#F00;margin-top:0px;margin-left:0px\">
<div><object width=\"212\" height=\"172\">
<param name=\"movie\" value=\"https://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&author=MobileTechReview&max-results=50\"></param>
<param name=\"wmode\" value=\"transparent\"></param>
<embed src=\"https://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&author=MobileTechReview&max-results=50\"
type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"212\" height=\"172\"></embed>
</object></div></body></html>";
[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.your-url.com"]];
}
To unsubscribe from this group and stop receiving emails from it, send an email to iphone-appdev-auditors+unsubscri...@googlegroups.com.
To post to this group, send email to iphone-appd...@googlegroups.com.
Visit this group at http://groups.google.com/group/iphone-appdev-auditors?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.