I'm not sure if the table view is what I would use but I'm having trouble figuring out how to store 10-20 audio files in a scrollable list like the iPod app and play a song when it is selected. Any help is appreciated.
MVC Patterns, have a data controller which has your data (or if you're lazy, in the viewController), have a tableview which gets the data via the index of the array from the data controller. On a didSelectRowAtIndex, play that sound that it gets also from the index from the same array..
What is your question exactly? because "i'm trying", isn't that helpful >.<
#import <UIKit/UIKit.h>
@interface TableViewViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
}
@end
#import "TableViewViewController.h"
@implementation TableViewViewController
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Identifier for retrieving reusable cells.
static NSString *cellIdentifier = @"MyCellIdentifier";
// Attempt to request the reusable cell.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// No cell available - create one.
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier];
}
// Set the text of the cell to the row index.
cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Show an alert with the index selected.
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Item Selected"
message:[NSString stringWithFormat:@"Item %d", indexPath.row]
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
This is the first app I've ever created so keep that in mind.
I'm not sure if the table view is what I would use but I'm having trouble figuring out how to store 10-20 audio files in a scrollable list like the iPod app and play a song when it is selected. Any help is appreciated.
You posted this same question on the "iPhone Dev SDK" forum, and I answered you there.
Duncan, that forum back up? Still as much spam as when I was active there? (under other name).
You posted the question today. Why ask if it's back up if you posted a new question today?
Me? I haven't been on iPhoneDevSDK in a long time..
Aren't you talking about the OP posting the question instead of me?
Oops, sorry. I thought your post was the OP. That'll teach me to read more carefully.