Вот моя проблема:Как перейти к следующей строке Tableview с помощью кнопки
При нажатии кнопки на DetailViewController Я хочу, чтобы получить данные о моей следующей строке.
Вот что я пытался до сих пор:
-(IBAction)next:(id)sender {
question.text = [questions objectAtIndex:indexPath.row+1];
}
Но теперь он принимает данные, хранящиеся в строке 1. Но я хочу, чтобы извлечь данные из следующей строки в строке.
question
это имя моего лейбла я хочу текст, который будет отображаться в
questions
это имя моего NSMutableArray O магазине мои данные в
Вот полный код:..
//
// NINDetailViewController.m
// NIN
//
// Created by Hegg Roger on 27.06.13.
// Copyright (c) 2013 Hegg. All rights reserved.
//
#import "NINDetailViewController.h"
#import "NIN.h"
@interface NINDetailViewController()
@end
@implementation NINDetailViewController
@synthesize transfer;
@synthesize content;
@synthesize questions;
@synthesize questions1;
@synthesize answers;
@synthesize question;
@synthesize questionTableView;
@synthesize indexPath;
/*
-(IBAction)next:(id)sender {
question.text = [questions objectAtIndex:indexPath.row+1];
}
-(IBAction)prev:(id)sender {
}
*/
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
questions = [[NSMutableArray alloc]initWithObjects:
@"1. Wie lautet die richtige Reihenfolge beim Arbeiten an elektrischen
Installationen (Arbeitssicherheit)?",
@"2. Was versteht man unter dem Begriff UVG?",
@"3. Was ist die wichtigste Bestimmung des UVGs?",nil];
questions1 = [[NSMutableArray alloc]initWithObjects:
@"1. Was bedeuten die Abkürzungen NIV/NIN/StV?",nil];
[super viewDidLoad];
content.text = transfer;
// question.text = [questions objectAtIndex:indexPath.row];
}
- (NSInteger)tableView : (UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [questions count];
}
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
static NSString *simpleTableIdentifier = @"questionCell";
UITableViewCell *cell = [questionTableView
dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:simpleTableIdentifier];
}
if ([content.text isEqualToString:@"Unfallverhütung"]) {
question.text = [questions objectAtIndex:indexPath.row];
}
else
if ([content.text isEqualToString:@"Grundlagen/Begriffe/Kennzeichnungen"]) {
question.text = [questions1 objectAtIndex:indexPath.row];
}
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
@TBlue: Я получил эту ошибку с предложением:
ТНХ для усилий, но несчастливо я получаю ошибки: (см Pic) – hEgg
я предлагаю вам взять хороший взгляд на первые три строки кода, который я отвечал. –
Еще раз спасибо, но полный код, который я написал dosn't, содержит ваше решение. Я попробовал, получил ошибки, снял скриншот и снова стирал его. Я забыл упомянуть, что я использую Storyboard и ARC. – hEgg