2012-03-01 66 views
1

我在我的应用程序中使用日期选择器我希望当我从日期选择器中选择日期并单击完成按钮我需要列出所有其他类中的所有东西在某些视图中发生在特定日期我选择了。哪种视图最​​适合我展示这些事情?iphone中的日期选择器

回答

2

正如你所说,你已经创建了datePicker,所以当你点击完成按钮。

1)将相应的数据存储到数组中,以便您可以将该数据显示在UItableView上。

2)创建TableView:在这里你只需要创建TableView并显示这些数据。假设已经收集了你的Array中的数据(如步骤1)。

按照给定的步骤在tableView中创建数据。

A)UiViewController创建的UItableView实例中,你要显示的TableView .H类

AS `UITableView *myTableView`; 

B)采用的UITableViewDataSource,在视图控制器的UITableViewDelegate协议,其中你要带的TableView C)创建表(以编程方式或通过IB(界面生成器) 这里我以编程方式显示

//you may call this Method View Loading Time.  
-(void)createTable{ 
    CGrect yourFrame=CGrectMake(0,20,320,400);//Set Desired Frame of Table; 
    myTableView=[[[UITableView alloc]initWithFrame:yourFrame style:UITableViewStylePlain] autorelease]; 
    myTableView.backgroundColor=[UIColor clearColor]; 
    myTableView.delegate=self; 
    myTableView.dataSource=self; 
    myTableView.separatorStyle= UITableViewCellSeparatorStyleNone; 
    myTableView.scrollEnabled=YES; 
    [self.view addSubview:myTableView]; 
} 

//Data Source method to create number of section in Table View 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
return 1; 
} 

// Data Source method to create number of rows section of a Table View 
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section { 
    return [yourMutableArray count]; 
} 
// Data Source method to create cells in Table View 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    static NSString *CellIdentifier = @"Cell"; 
    //here you check for PreCreated cell. 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    //Fill the cells... 
    cell.textLabel.text = [yourMutableArray objectAtIndex: indexPath.row]; 
    //yourMutableArray Contains the Data(When You click On Done Button this array will stored the data). 
return cell; 
} 

我希望它会真的帮助你。

+0

它确实帮助我thanx很多 – 2012-03-01 14:18:29

1

我认为UItableView将是不错的选择。

+0

我该怎么做? – 2012-03-01 12:26:33

+0

看看:http://www.mobisoftinfotech.com/blog/iphone/introduction-to-table-view/ – Apurv 2012-03-01 12:28:16

0

我认为它更好地使用泰伯维只因为改变u必须改变数据也是此日期之后,因此,如果u使用表格视图,我们只要简单的重启的tableview这将是简单

+0

yah.thnx克里希纳 – 2012-03-01 14:19:19

-1

一旦你点击完成按钮,查询获取所有数据的基础上选定的数据,并将其存储在一些阵列...并重新加载表视图与数组中的数据...