嗨,我遇到了 DetailViewController 不想设置 UILabel 插座的问题,这是一个 Master Detail 应用程序模板,当我按下一个单元格时会发生什么
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
// here it accordingly sets the ObjectItem to my custom object.
Torrent *object = _torrents[indexPath.row];
[[segue destinationViewController] setObjectItem:object];
}
}
这里是我在 DetailViewController viewDidLoad 中调用的方法
- (void)configureView
{
// Since i set the objectItem earlier it works, it set the outlets
if (self.objectItem) {
theTitle.text = self.objectItem.MovieTitleClean;
genre.text = self.objectItem.Genre;
size.text = self.objectItem.Size;
quality.text = self.objectItem.Quality;
rating.text = self.objectItem.MovieRating;
year.text = self.objectItem.MovieYear;
}
if (self.detailObject) {
ShortDescription.lineBreakMode = NSLineBreakByWordWrapping;
self.details = [_detailObject objectAtIndex:0];
NSLog(@"Called"); // this is called meaning it should set the outlets but it doesn't...
resolution.text = self.details.Resolution;
framerate.text = self.details.FrameRate;
language.text = self.details.Language;
peersSeeds.text = [NSString stringWithFormat:@"%@/%@",self.details.TorrentPeers,self.details.TorrentSeeds];
downloaded.text = self.details.Downloaded;
ShortDescription.text = self.details.ShortDescription;
}
在 DetailViewController viewDidLoad 我调用 configureView 它将 UILabel 出口设置为我的自定义 objectItem 并且效果很好,但是当我从委托接收新的 detailObject 并根据该新 detailObject 设置其他 UILabel 时,似乎根本没有设置任何东西(注意)视图已经加载,一个 NSlog 显示我调用了 configureView,这意味着它假设设置了网点,我必须等待 15 秒,它会自动设置它们,有人知道为什么视图没有响应吗?它首先做到了。谢谢
编辑:这是 .h 文件
#import <UIKit/UIKit.h>
#import "TorrentDetail.h"
#import "YifyAPI.h"
#import "Torrent.h"
@interface DetailViewController : UIViewController <YifyAPIDelegate> {
IBOutlet UILabel *theTitle;
IBOutlet UILabel *genre;
IBOutlet UILabel *size;
IBOutlet UILabel *quality;
IBOutlet UILabel *rating;
IBOutlet UILabel *year;
IBOutlet UILabel *resolution;
IBOutlet UILabel *framerate;
IBOutlet UILabel *language;
IBOutlet UILabel *peersSeeds;
IBOutlet UILabel *downloaded;
IBOutlet UILabel *ShortDescription;
IBOutlet UIImageView *LargeImageCover;
}
@property (strong, nonatomic) Torrent *objectItem;
@property (strong, nonatomic) TorrentDetail *detailObject;
@end