我正在創建一個具有主詳細視圖概念的iPad應用程序(iOS6.1)。第一個視圖是一個表視圖,其中包含從Plist中加載的項目列表,當每個行被選中時,第二個表視圖被另一個Plist加載。他們是我的細節視圖,它必須用UILabel和UIImage顯示UIView。我正在使用didSelectRowAtIndexPath
方法。前兩個表視圖是正確顯示和加載該行並顯示相應的視圖,但是這是應該顯示的UILabel最後的細節視圖和圖像是空的,任何一個可以幫助我解決這個問題xCode詳細視圖爲空
我的代碼爲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
Implemetation文件有
@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);
}
沒有看到的那樣選擇行的代碼或SEGUE代碼取決於你是否使用xib或storyboard,回答你的問題幾乎是不可能的。 –
這是我正在使用的代碼 –
語法錯誤之前第三'if' - >刪除'}' –