如何在不同的表格视图单元格中更改信息

时间:2015-12-27 13:06:19

标签: ios objective-c iphone uitableview

使用多个教程我创建了一个成功的Table View应用程序应用程序。前两个单元格我只将图片和信息插入到单元格中。但是,现在我想在三个单元格中插入视频,Web视图和地图视图,这可能吗?

我已经在不同的Xcode项目上创建了一个视频,网页视图和地图视图应用,现在我不知道我怎么能"插入"他们进入我的表视图应用程序。

我真的很开心,感谢你的帮助! :))

干杯菲利普 (如果你想仔细看看我的项目,我发送你的Xcode项目没问题)

The first two cells I have edited information into,however I don't know how I can insert Videos-Unsere Videos...... Web page- Unsere Webseite Map View- Wo Sie uns finden..... into the three other cells

Main Storyboard

2 个答案:

答案 0 :(得分:0)

关于tableView的好处它可以像你想要的那样变化。要添加您选择的UITableViewCell,请首先配置cell(使用故事板或代码),然后执行以下操作:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {//this line can vary according to your requierment
        case 0:
            //RETURN image cell
            break;
        case 1:
            //RETURN image cell
            break;
        case 2:
            //RETURN Video player cell
            break;
        case 3:
            //RETURN webview cell
            break;
        case 4:
            //RETURN any other cell
            break;

        default:
            //RETURN default cell
            break;
    }
    return nil;
}

答案 1 :(得分:0)

从UItableViewCell创建一个类Costtom并将此类导入headefile到主类,并使用class costom创建UITableViewCell,例如:

PriceTableViewCell.h:

#import <UIKit/UIKit.h>

@interface PriceTableViewCell : UITableViewCell
     @property(nonatomic,retain)NSString *nameString;
     @property(nonatomic,retain)NSString *titleString;
     @property(nonatomic,retain)NSString *priceString;
     @property(nonatomic,retain)NSString *dateString;
     @property(nonatomic,retain)NSString *ownerString;
@end

PriceTableViewCell.m:

#import "PriceTableVIewCell.h"
@impliment PriceTableViewCell

@end

和PrimaryClass.m:

 #import "PriceTableViewCell.h"
 ....//code here
 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     static NSString *MyIdentifier = @"CustomerCell";
     UITableViewCell *cell = (PriceTableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
     if(cell==nil){
          cell =  [[PriceTableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:MyIdentifier];
     }
     ...//code here
}
相关问题