2013-03-07 82 views
1

我需要幫助。我已經將xcode更新爲最新版本,並且當我嘗試獲取測試時,舊代碼將引發錯誤「類不是關鍵值scrollView的鍵值編碼」。這個類不是關鍵值編碼兼容的關鍵scrollView

有趣的是,這裏沒有滾動視圖。我有其他看法幾乎精確的代碼,它工作正常。這是代碼。這也沒有筆尖,所以從視圖中取出滾動視圖將不起作用。

 

       #import "pearGalleryController.h" 
       #import "pearGallery.h" 

       @implementation pearGalleryController 

       - (void)viewDidLoad { 
        [super viewDidLoad]; 

        self.tableView.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:100]; 
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 
        self.navigationItem.title = @"Variety of Pears"; 

       } 



       - (void)didReceiveMemoryWarning { 
        // Releases the view if it doesn't have a superview. 
        [super didReceiveMemoryWarning]; 

        // Release any cached data, images, etc that aren't in use. 
       } 

       - (void)viewDidUnload { 

       } 


       #pragma mark Table view methods 

       - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
        return 1; 
       } 


       // Customize the number of rows in the table view. 
       - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
        return 3; 
       } 

       - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; 
       { 
        return 122; 
       } 

       // Customize the appearance of table view cells. 
       - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

        static NSString *CellIdentifier = @"Cell"; 

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
        if (cell == nil) { 
         // cell is an object of the UITableViewCell this assign an object to a cell 2 memory areas, o need to auto release on the alloc bcause it is an object 
         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
        } 

        cell.selectionStyle = UITableViewCellSelectionStyleNone; 
        // Set up the cell... 
        int picIndex = [indexPath row]*3; 

        UIButton* tempView = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 107,123)]; 

        [tempView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pears_%d.png",picIndex]] 
           forState:UIControlStateNormal]; 

        tempView.tag = picIndex; 
        [tempView addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside]; 
        [cell.contentView addSubview:tempView]; 
        [tempView release]; 

        tempView = [[UIButton alloc]initWithFrame:CGRectMake(106, 0, 107,123)]; 

        [tempView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pears_%d.png",picIndex+1]] 
           forState:UIControlStateNormal]; 

        tempView.tag = picIndex+1; 
        [tempView addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside]; 
        [cell.contentView addSubview:tempView]; 
        [tempView release]; 


        tempView = [[UIButton alloc]initWithFrame:CGRectMake(212, 0, 107,123)]; 

        [tempView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pears_%d.png",picIndex+2]] 
           forState:UIControlStateNormal]; 

        tempView.tag = picIndex+2; 
        [tempView addTarget:self action:@selector(buttonClick:)  
        forControlEvents:UIControlEventTouchUpInside]; 

        [cell.contentView addSubview:tempView]; 
        [tempView release];  



        return cell; 
        } 


        -(void)buttonClick:(id)sender 



        { 
        UIButton* btn = (UIButton*)sender; 
        int index = btn.tag; 

        pearGallery *anotherViewController = [[pearGallery alloc] initWithNibName:@"pearGallery" bundle:[NSBundle mainBundle]]; 

        anotherViewController.myIndex = index; 

        [self.navigationController pushViewController:anotherViewController animated:YES]; 
        [anotherViewController release]; 



        UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil]; 
        //UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"video.png"] style:UIBarButtonItemStylePlain target:nil action:nil]; 
        self.navigationItem.backBarButtonItem = backButton; 
        [backButton release]; 

       } 


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

       } 

       - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
        return (interfaceOrientation == UIInterfaceOrientationPortrait); 
       } 

       - (void)dealloc { 
        [super dealloc]; 
       } 


       @end 

和H文件

 

    #import 


    @interface pearGalleryController : UITableViewController { 

    } 

    @end 

回答

1

可能在你的XIB文件懸空參考,檢查以確保引用都被清除。

0

,當你有一個對象,你的情況是通常會發生此錯誤「滾動視圖」它通過接口生成器在情節提要/廈門國際銀行的滾動視圖項目連接。

檢查您在界面構建器中的鏈接(最右邊的選項卡),並且沒有重複鏈接到另一個IBOutlet。

我覺得這是隻有當我鏈接了一個對象,然後「錯誤地輸入」我的鏈接,我去改變它,但不從界面生成器即滾動型和scroLLview2

圍棋刪除舊的鏈接發生在我到你的界面生成器(連接選項卡),並檢查你沒有重複的鏈接。 刪除所有鏈接到你的「滾動型」和「重新連接」到你的.h文件中,然後再試一次

您可能鍵入滾動視圖然後將其更改爲滾動型,而不是運氣realised..good

相關問題