xCode详细信息视图为空

时间:2013-06-05 04:36:15

标签: ios objective-c xcode uiviewcontroller master-detail

我正在创建一个具有主细节视图概念的iPad应用程序(iOS6.1)。第一个视图是一个表视图,其中包含从Plist加载的项目列表,当每一行被选中时,第二个表视图将加载另一个Plist。他们是我的详细视图,它必须显示带有UILabel和UIImage的UIView。我正在使用didSelectRowAtIndexPath方法。前两个表视图已正确显示并加载行并显示相应的视图但最后一个应该显示UILabel的图像是空的,任何人都可以帮我解决这个问题

My application flow

didSelectRowAtIndexPath方法的代码是

 -(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标题

#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

实施文件

@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);

}

1 个答案:

答案 0 :(得分:0)

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

TaskDetailViewController *newTaskDetailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];