2010-04-08 67 views
1

我有一個包含一個滾動視圖有兩個子視圖的應用程序(向左滾動它們之間右)爲什麼我TTTableViewController不會出現

這兩種觀點都正確顯示和視圖之間滾動工作得很好。現在我想將第一個視圖改爲TTTableView(禮貌Three20),但是當我使用TTCatalog應用程序中的類「TableControlsTestController」時,我只能看到一個空表tableView

請注意,該類包含所有數據顯示6細胞

要添加新的TTTableView我用下面的

[scrollView addSubview:detailView.view]; 

其中的DetailView是TableControlsTestController

實例

要儘量縮小問題出在哪裏我還牛逼ried致電

[self presentModalViewController:detailView animated:YES]; 

這正確顯示了與6個單元格的tableview。

爲什麼當我嘗試添加視圖到scrollView這不工作,因爲我期望?


僅供參考,如果你沒有訪問TTCatalog

#import "TableControlsTestController.h" 

/////////////////////////////////////////////////////////////////////////////////////////////////// 

@implementation TableControlsTestController 

/////////////////////////////////////////////////////////////////////////////////////////////////// 
// NSObject 

- (id)init { 
    if (self = [super init]) { 
    self.tableViewStyle = UITableViewStyleGrouped; 
    self.autoresizesForKeyboard = YES; 
    self.variableHeightRows = YES; 

    UITextField* textField = [[[UITextField alloc] init] autorelease]; 
    textField.placeholder = @"UITextField"; 
    textField.font = TTSTYLEVAR(font); 

    UITextField* textField2 = [[[UITextField alloc] init] autorelease]; 
    textField2.font = TTSTYLEVAR(font); 
    textField2.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; 
    TTTableControlItem* textFieldItem = [TTTableControlItem itemWithCaption:@"TTTableControlItem" 
                  control:textField2]; 

    UITextView* textView = [[[UITextView alloc] init] autorelease]; 
    textView.text = @"UITextView"; 
    textView.font = TTSTYLEVAR(font); 

    TTTextEditor* editor = [[[TTTextEditor alloc] init] autorelease]; 
    editor.font = TTSTYLEVAR(font); 
    editor.backgroundColor = TTSTYLEVAR(backgroundColor); 
    editor.autoresizesToText = NO; 
    editor.minNumberOfLines = 3; 
    editor.placeholder = @"TTTextEditor"; 

    UISwitch* switchy = [[[UISwitch alloc] init] autorelease]; 
    TTTableControlItem* switchItem = [TTTableControlItem itemWithCaption:@"UISwitch" control:switchy]; 

    UISlider* slider = [[[UISlider alloc] init] autorelease]; 
    TTTableControlItem* sliderItem = [TTTableControlItem itemWithCaption:@"UISlider" control:slider]; 

    self.dataSource = [TTListDataSource dataSourceWithObjects: 
     textField, 
     editor, 
     textView, 
     textFieldItem, 
     switchItem, 
     sliderItem, 
     nil]; 
    } 
    return self; 
} 

@end 

回答

2

事實證明,一些事件沒有被通過了滾動傳播,因此在TTTableViewController沒有處理。爲了解決這個問題,我不得不做我的滾動視圖

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [myNewTTViewController viewWillAppear:NO]; 
} 


- (void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    [myNewTTViewController viewDidAppear:NO]; 
} 

- (void)viewWillDisappear:(BOOL)animated { 
    [super viewWillDisappear:animated]; 
    [myNewTTViewController viewWillDisappear:NO]; 
} 

- (void)viewDidDisappear:(BOOL)animated { 
    [super viewDidDisappear:animated]; 
    [myNewTTViewController viewDidDisappear:NO]; 
} 

以下只要我做這個表突然出現在生活

+0

我是有這個問題了。謝謝,利亞姆。 – thebossman 2010-07-03 01:12:02

+0

我也是。我不知道自己怎麼想到這一點。謝啦。 – 2010-09-09 03:15:22