Hi, everyone
I'm now doing about editing data from image. My first page has many images so when the user choose one of those image, it is going to another view which consists about details. I used the Round Rect Button to display my image. My problem is when I choose one of those image the data always be the same as the first image. Here is my code;
If somebody can help me find out, please tell me
Thank you Sir!
this is code for 1st page
and this is the last page
I'm now doing about editing data from image. My first page has many images so when the user choose one of those image, it is going to another view which consists about details. I used the Round Rect Button to display my image. My problem is when I choose one of those image the data always be the same as the first image. Here is my code;
If somebody can help me find out, please tell me
Thank you Sir!
Code:
// from appDelegate
Character *bradpit = [[Character alloc] init];
bradpit.cName = @"BradPitt";
bradpit.cDescription = @"Good looking \nPositive \nCool";
bradpit.cPicture = [UIImage imageNamed:@"bradpitt.png"];
Character *angy = [[Character alloc] init];
angy.cName = @"Angelina Jolie";
angy.cDescription = @"Beautiful";
angy.cPicture = [UIImage imageNamed:@"angy.png"];
Character *arnold = [[Character alloc] init];
arnold.cName = @"Arnold";
arnold.cDescription = @"Muscle";
arnold.cPicture = [UIImage imageNamed:@"arnold.png"];
Character *bruce = [[Character alloc] init];
arnold.cName = @"Bruce";
arnold.cDescription = @"xkjx";
arnold.cPicture = [UIImage imageNamed:@"Bruce.png"];
self.characters = [[NSMutableArray alloc]initWithObjects:bradpit,angy,arnold,bruce,nil];
[bradpit release];
[angy release];
[arnold release];
[bruce release];
[window addSubview:rootController.view];
[window makeKeyAndVisible];
this is code for 1st page
Code:
- (void)viewDidLoad {
self.title = @"First Page";
UIBarButtonItem *moveButton = [[UIBarButtonItem alloc]initWithTitle:@"Setting" style:UIBarButtonItemStyleDone target:self action:@selector(setting)];
self.navigationItem.rightBarButtonItem = moveButton;
[moveButton release];
BBAppDelegate *delegate = (BBAppDelegate *)[[UIApplication sharedApplication] delegate];
character = delegate.characters;
[super viewDidLoad];
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"cell"];
if(cell == nil){
cell = [[[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:@"cell"]autorelease];
}
Character *thisCharacter = [character objectAtIndex:indexPath.row];
cell.textLabel.text = thisCharacter.cName;
return cell;
}
}
and this is the last page
Code:
- (void)viewDidLoad {
UIBarButtonItem *moveButton = [[UIBarButtonItem alloc]initWithTitle:@"Edit" style:UIBarButtonItemStyleDone target:self action:@selector(edit)];
self.navigationItem.rightBarButtonItem = moveButton;
[moveButton release];
BBAppDelegate *delegate = (BBAppDelegate *)[[UIApplication sharedApplication] delegate];
Character *thisCharacter = [delegate.characters objectAtIndex:[index row]];
self.title = thisCharacter.cName;
descriptionView.text = thisCharacter.cDescription;
descriptionView.editable = NO;
pictureView.image = thisCharacter.cPicture;
[super viewDidLoad];
}