Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.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
Iphone 在基于导航的应用程序中使用UIVIewController填充UIView_Iphone_Objective C_Uiviewcontroller_Setter - Fatal编程技术网

Iphone 在基于导航的应用程序中使用UIVIewController填充UIView

Iphone 在基于导航的应用程序中使用UIVIewController填充UIView,iphone,objective-c,uiviewcontroller,setter,Iphone,Objective C,Uiviewcontroller,Setter,我正在制作一个用于在基于导航的应用程序中列出电影的测试应用程序,该应用程序使用我在应用程序:didfishlaunchingwithoptions:中的appDelegate中读取的plist文件中的数据。当我尝试转到第二个detailViewController时,我得到了部分更改的标题(我得到的是电影的标题,但不是UIView中的年份。标题我得到了类似“78898320”&空UIImageView&UILabels的内容。我缺少什么 以下是我在rootViewController中的方法

我正在制作一个用于在基于导航的应用程序中列出电影的测试应用程序,该应用程序使用我在
应用程序:didfishlaunchingwithoptions:
中的appDelegate中读取的plist文件中的数据。当我尝试转到第二个detailViewController时,我得到了部分更改的标题(我得到的是电影的标题,但不是
UIView中的年份。标题
我得到了类似“78898320”&空UIImageView&UILabels的内容。我缺少什么

以下是我在rootViewController中的方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath     *)indexPath
{
NSLog(@"YOU SELECTED: %d",indexPath.row);

detailViewController *detailView = [[detailViewController alloc] initWithNibName:@"detailViewController" bundle:nil];

NSDictionary *dict = [NSDictionary dictionaryWithDictionary:
                      [movies objectAtIndex:indexPath.row]];

[detailView fill:dict];

[self.navigationController pushViewController:detailView animated:YES];
[detailView release];

}
-(void)fill: (NSDictionary*) fillData
{
//movie = [NSDictionary dictionaryWithDictionary:fillData];
NSLog(@"DETAILS: %@",[fillData objectForKey:@"description"]);

self.title = [NSString stringWithFormat:@"%@ (%d)",
              [fillData objectForKey:@"title"],
              [fillData objectForKey:@"year"]];
//[movie objectForKey:@"title"];
self.img = [[UIImageView alloc] initWithImage:
            [UIImage imageNamed:[fillData objectForKey:@"image"]]];
self.description = [fillData objectForKey:@"description"];
self.cast = [fillData objectForKey:@"cast"];
}
以下是我在detailViewController中填充UIView的方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath     *)indexPath
{
NSLog(@"YOU SELECTED: %d",indexPath.row);

detailViewController *detailView = [[detailViewController alloc] initWithNibName:@"detailViewController" bundle:nil];

NSDictionary *dict = [NSDictionary dictionaryWithDictionary:
                      [movies objectAtIndex:indexPath.row]];

[detailView fill:dict];

[self.navigationController pushViewController:detailView animated:YES];
[detailView release];

}
-(void)fill: (NSDictionary*) fillData
{
//movie = [NSDictionary dictionaryWithDictionary:fillData];
NSLog(@"DETAILS: %@",[fillData objectForKey:@"description"]);

self.title = [NSString stringWithFormat:@"%@ (%d)",
              [fillData objectForKey:@"title"],
              [fillData objectForKey:@"year"]];
//[movie objectForKey:@"title"];
self.img = [[UIImageView alloc] initWithImage:
            [UIImage imageNamed:[fillData objectForKey:@"image"]]];
self.description = [fillData objectForKey:@"description"];
self.cast = [fillData objectForKey:@"cast"];
}

当我尝试使用NSLog从字典中打印描述时,它打印得很好。

您使用的对象是
%d

[fillData objectForKey:@"year"]

您应该改用
%@
,因为它很可能是一个
NSNumber
对象。

您使用的对象是
%d

[fillData objectForKey:@"year"]
-(void)fill: (NSDictionary*) fillData
{
    //movie = [NSDictionary dictionaryWithDictionary:fillData];
    NSLog(@"DETAILS: %@",[fillData objectForKey:@"description"]);

    self.title = [NSString stringWithFormat:@"%@ (%d)",
          [fillData objectForKey:@"title"],
          [[fillData objectForKey:@"year"] intValue]];
    //[movie objectForKey:@"title"];
    self.img = [[UIImageView alloc] initWithImage:
          [UIImage imageNamed:[fillData objectForKey:@"image"]]];
    self.description = [fillData objectForKey:@"description"];
    self.cast = [fillData objectForKey:@"cast"];
}
您应该改用
%@
,因为它很可能是一个
NSNumber
对象

-(void)fill: (NSDictionary*) fillData
{
    //movie = [NSDictionary dictionaryWithDictionary:fillData];
    NSLog(@"DETAILS: %@",[fillData objectForKey:@"description"]);

    self.title = [NSString stringWithFormat:@"%@ (%d)",
          [fillData objectForKey:@"title"],
          [[fillData objectForKey:@"year"] intValue]];
    //[movie objectForKey:@"title"];
    self.img = [[UIImageView alloc] initWithImage:
          [UIImage imageNamed:[fillData objectForKey:@"image"]]];
    self.description = [fillData objectForKey:@"description"];
    self.cast = [fillData objectForKey:@"cast"];
}
如果您没有在图像视图中获取图像,因为您没有设置其帧,并且您没有将其添加到视图中(至少在这里)


如果您没有在图像视图中获取图像,因为您没有设置其帧,并且您没有将其添加到视图中(至少在这里)…

您必须更改一些内容才能使其正常工作。我猜您所有的标签和图像视图实际上都在NIB文件中

通过这样做:

self.img = [[UIImageView alloc] initWithImage:
            [UIImage imageNamed:[fillData objectForKey:@"image"]]];
通过使用新实例替换NIB文件中的属性和对象,实际上正在断开该属性和对象之间的连接。除非手动将新实例添加到视图中,否则不会显示任何内容

尝试使用:

[self.img setImage:[UIImage imageNamed:[fillData objectForKey:@"image"]]];
这同样适用于:

self.description = [fillData objectForKey:@"description"];
self.cast = [fillData objectForKey:@"cast"];
请尝试:

[self.description setText:[fillData objectForKey:@"description"]];
[self.cast setText:[fillData objectForKey:@"cast"]];

你必须改变一些东西才能工作。我想你所有的标签和图像视图实际上都在一个NIB文件中

通过这样做:

self.img = [[UIImageView alloc] initWithImage:
            [UIImage imageNamed:[fillData objectForKey:@"image"]]];
通过使用新实例替换NIB文件中的属性和对象,实际上正在断开该属性和对象之间的连接。除非手动将新实例添加到视图中,否则不会显示任何内容

尝试使用:

[self.img setImage:[UIImage imageNamed:[fillData objectForKey:@"image"]]];
这同样适用于:

self.description = [fillData objectForKey:@"description"];
self.cast = [fillData objectForKey:@"cast"];
请尝试:

[self.description setText:[fillData objectForKey:@"description"]];
[self.cast setText:[fillData objectForKey:@"cast"]];

self.title
self.img
,…在
detailViewController
中的声明如何?没有任何东西会向我跳出来,你应该设置一个断点并逐步执行。只需设置detailView.title=@“Transformers”。您将无法获得这些数字。@Vince self.title是视图的标题,而img、description和cast是在viewController界面中定义的UIImageView和2个UILabels。@Legolas,我对标题没有任何问题,只有UIImageView和UILabels现在困扰着我。正如您在下面的回答中所看到的。
self.tit怎么样le
self.img
,…在
detailViewController
中声明?没有任何东西会跳到我身上,你应该设置一个断点并逐步通过它。只需设置detailView.title=@“Transformers”。你不会得到这些数字。@Vince self.title是视图的标题,而img、description和cast是在viewController界面中定义的UIImageView和2个UILabels。@Legolas,我对标题没有任何问题,只有UIImageView和UILabels现在困扰着我。正如你在下面的答案中所看到的那样。你是对的。我应该这样做使用我在NSLog中使用的
%@
。现在该部件工作正常,但为什么我的UIImageView和UILabels没有填充?填充它们的位置是哪里?正确的点应该是
viewDidLoad
ViewWill将显示:
,因为之前没有进行插座连接。如果您已经这样做了,请检查您的插座连接ns.我的IBOutlet连接很好..现在我尝试在FillData方法中初始化NSDictionary并稍后使用它填充UIImageView&UILabels inside Viewwills..当它到达那里时,NSDictionary包含了数据,但没有填充数据。你说得对。我应该使用NSLog中使用的
%@
。现在不行帽子部分工作正常,但为什么我的UIImageView&UILabel没有填充?您在哪里填充它们?正确的点应该是
viewDidLoad
view将出现:
,因为之前没有进行插座连接。如果您已经这样做了,请检查您的插座连接。我的IBOutlet连接很好。现在我也没有ried初始化NSDictionary inside FillData方法并稍后使用它填充UIImageView&UILabels inside View将出现..当它到达那里时,NSDictionary包含数据,但没有填充它们。确实是..当我在我的
FillData:
method中通过NSDictionary传递数据时,我使用
Vi中的数据EWillappear:
method来填充我的属性..它实际上是有效的..谢谢!是的..当我通过我的
fillData:
method中的NSDictionary传递数据时:view中的数据将出现:method来填充我的属性..它确实有效..谢谢!