0

I am creating an iPad application (iOS6.1) which has a master detail view concept. First view is a table view has list of items that are been loaded from Plist, when each row gets selected the second table view gets loaded with another Plist. theirs is my Detail view which has to display an UIView with a UILabel ans an UIImage. I am using didSelectRowAtIndexPath method . The first two table Views are been displayed properly and loads the row and display corresponding View but the last detail view which is supposed to display the UILabel and an image is empty, can any one help me to solve this problem

My application flow

My Code for the didSelectRowAtIndexPath method is

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

 {

TaskDetailViewController *newTaskDetailViewController = [[TaskDetailViewController alloc] init];

// pass the row to newDetailViewController

if (weekNumber == 0)
{
    newTaskDetailViewController.taskdescription = [weeklist1 objectAtIndex:indexPath.row];

}
if (weekNumber == 1)
{
    newTaskDetailViewController.taskdescription = [weeklist2 objectAtIndex:indexPath.row];

}

if (weekNumber == 2)
{
    newTaskDetailViewController.taskdescription = [weeklist3 objectAtIndex:indexPath.row];

}
// ...... repeated for 39 times because of the list


 newTaskDetailViewController.taskNumber = indexPath.row;
[self.navigationController pushViewController:newTaskDetailViewController animated:YES];
}

DetailView header

#import <UIKit/UIKit.h>

@interface TaskDetailViewController : UIViewController

@property int taskNumber;

@property(strong , nonatomic) NSString *taskdescription;

@property (nonatomic , strong) NSMutableDictionary * tasks;

@property (strong, nonatomic) IBOutlet UIImageView *questionImage;

@property (strong, nonatomic) IBOutlet UILabel *displayText;

@end

Implemetation file has

@implementation TaskDetailViewController

@synthesize taskNumber;

@synthesize taskdescription;

@synthesize tasks;

@synthesize displayText;

@synthesize questionImage;


-(void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view.

self.title = taskdescription;

NSLog(@"%@", taskdescription);

}
4

1 回答 1

0

您的问题是使用 alloc init 创建 TaskDetailViewController 的实例。您已经在情节提要中创建了该控制器,因此您应该使用您提供的标识符(在我的示例中为 DetailViewController)从情节提要中实例化它:

TaskDetailViewController *newTaskDetailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
于 2013-06-05T05:22:33.890 回答