相关疑难解决方法(0)

一个UIView上的多个UITableViews

我需要在一个UIView上有两个UITableViews.我可以使用它,这是代码:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [contentOne count];  // sets row count to number of items in array
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    NSString *firstValue = [[NSString alloc] initWithFormat: @"Row %i% %", indexPath.row+1 ];
    NSString *secondValue = [contentOne objectAtIndex:indexPath.row];

    NSString *cellValue = [firstValue stringByAppendingString: secondValue]; // …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview

10
推荐指数
3
解决办法
2万
查看次数

如何在1个viewController中管理2个tableviews?

有谁知道在一个viewController中管理几个tableViews的简单方法?到目前为止,我一直在这样做:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{
if(tableView == self.tableView1) 
return 1;
else if(tableView == self.tableView2) 
return 2;
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(tableView == self.tableView1) 
return @"bla";
else if(tableView == self.tableView2) 
return @"blabla";
}

-(NSString *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView == self.tableView1) 
...
else if(tableView == self.tableView2) 
...
}
Run Code Online (Sandbox Code Playgroud)

我发现我必须为每个单一委托方法使用if/else语句真的很烦人.另外,当有很多tableView时,它真的很难读.此外,我对NSURLConnection等有同样的问题......只要我有几个对象响应相同的委托协议,事情就会变得混乱.

让事情变得简单的最好方法是什么?谢谢

iphone delegates uitableview

8
推荐指数
2
解决办法
7782
查看次数

单个视图上的2个tableview

我需要一个示例或解释如何填充在同一视图上的2个表视图.我需要了解"cellForRowAtIndexPath"方法,有人可以给我一个关于代码应该如何的例子吗?

我的意思是如何识别哪个表视图?

谢谢

下面是我的cellForRowAtIndexPath方法:

 // 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 = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

// Configure the cell...
// Set up the cell
MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
    if (tableView == radios_tv) { //radio_tv is an IBOutleet UITableView
        sqlClass *aRadio = (sqlClass *)[appDelegate.array_radios objectAtIndex:indexPath.row];
        [cell setText:aRadio.r_name];
        return cell;
    }
    if …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uitableview ios

4
推荐指数
1
解决办法
6283
查看次数

如何在适用于iPad的View Controller中创建多个表视图?

我正在使用通用应用程序.现在我想在iPAD的视图控制器中创建三个表视图.我有三个独立的视图控制器与XIB.So我如何在主控制器中添加另外两个表视图作为子视图.请给我一些示例应用程序和链接.在我的应用程序中,我有三个视图控制器并添加一个子视图作为表视图(而不是UITableViewController).在单击第一个表视图数据时,它导航到第二个表并单击第二个表视图数据,它将导航到第三个表视图.

 Hierarchy:

   MainViewController:
     --SubTableView1 
     --SubTableView2 
Run Code Online (Sandbox Code Playgroud)

见下图, 替代文字

请帮帮我.

谢谢!!

uitableview uiviewcontroller ipad

3
推荐指数
1
解决办法
1万
查看次数