Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode initWithStyle:UITableViewCellStyleSubtitle但未显示字幕_Xcode - Fatal编程技术网

Xcode initWithStyle:UITableViewCellStyleSubtitle但未显示字幕

Xcode initWithStyle:UITableViewCellStyleSubtitle但未显示字幕,xcode,Xcode,我正在尝试使用initWithStyle为表运行以下代码:UITableViewCellStyleSubtitle,但该副标题未显示。你能告诉我怎么了吗 提前谢谢 #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize listData; - (void)viewDidLoad { [super viewDidLoad];

我正在尝试使用initWithStyle为表运行以下代码:UITableViewCellStyleSubtitle,但该副标题未显示。你能告诉我怎么了吗

提前谢谢

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize listData;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSArray *array = [[NSArray alloc] initWithObjects:@"Sleepy", @"Sneezy", @"Bashful", @"Happy", @"Doc", @"Grumpy", @"Dopey", @"Thorin", @"Dorin", @"Nori", @"Ori", @"Balin", @"Dwalin", @"Fili", @"Kili", @"Oin", @"Gloin", @"Bifur", @"Bofur", @"Bombur", nil];
    self.listData = array;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    self.listData = nil;
}

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

#pragma mark -
#pragma mark Table View Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView
    numberOfRowsInSection:(NSInteger)section
{
    return [self.listData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]
                initWithStyle:UITableViewCellStyleSubtitle 
                reuseIdentifier:SimpleTableIdentifier];
    }

    UIImage *image = [UIImage imageNamed:@"star.png"];
    cell.imageView.image = image;

    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex:row];
    return cell;

    if (row < 7)
        cell.detailTextLabel.text = @"Mr. Disney";
    else
        cell.detailTextLabel.text = @"Mr.Tolkien";
}

@end
#导入“ViewController.h”
@界面视图控制器()
@结束
@实现视图控制器
@综合列表数据;
-(无效)viewDidLoad
{
[超级视图下载];
//加载视图后,通常从nib执行任何其他设置。
NSArray*数组=[[NSArray alloc]initWithObjects:“困倦”、“打喷嚏”、“害羞”、“快乐”、“多愁善感”、“暴躁”、“多愁善感”、“索林”、“多林”、“诺丽”、“奥利”、“巴林”、“德瓦林”、“菲利”、“基利”、“奥恩”、“格洛因”、“比弗”、“波弗尔”、“邦布尔”、“奈尔”);
self.listData=数组;
}
-(无效)视图卸载
{
[超级视频下载];
//释放主视图的所有保留子视图。
self.listData=nil;
}
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation
{
返回(interfaceOrientation!=UIInterfaceOrientation肖像向上向下);
}
#布拉格标记-
#pragma标记表视图数据源方法
-(NSInteger)表视图:(UITableView*)表视图
节中的行数:(NSInteger)节
{
返回[self.listdatacount];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*SimpleTableIdentifier=@“SimpleTableIdentifier”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
如果(单元格==nil){
单元格=[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:SimpleTableIdentifier];
}
UIImage*image=[UIImage ImageName:@“star.png”];
cell.imageView.image=图像;
NSUTEGER行=[indexPath行];
cell.textlab.text=[listData objectAtIndex:row];
返回单元;
如果(第7行)
cell.detailtextlab.text=@“迪士尼先生”;
其他的
cell.detailtextlab.text=@“Mr.Tolkien”;
}
@结束
应该是最后一行。它在设置
detailtextlab
text
属性之前返回

此外,您还应该收到来自Xcode的关于“无法访问代码”的警告

return cell;