我想加載另一個視圖,當我點擊我的UITableCell
視圖之一,但沒有任何在xib文件(與該視圖相關)的東西正在顯示。物品在視圖中沒有出現在加載
這是我如何初始化的觀點(在生成tableView
控制器):
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Cards";
self.detailController = [[BasicCardViewController alloc] initWithNibName: @"CardView" bundle:nil];
}
return self;
}
這是我處理的選擇:
- (void)tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *component = self.resultsTuples[indexPath.row];
[AJAXUtils getAsyncJsonWithUrl:(NSURL *)[NSURL URLWithString:someUrl] callback:^(NSDictionary *returnjson) {
if (returnjson != nil) {
NSString *userPageLink = returnjson[@"Node"][@"SessionInfo"][@"PostingAs"][@"Key"];
self.detailController.userPageLink = userPageLink;
self.detailController.nodePage = returnjson[@"Node"][@"Key"];
NSString *selectedCard = component[@"$element"][@"Title"];
[self.detailController setDescription:component[@"element"][@"ContactCard"][@"Description"]];
[self.detailController setPageTitle:selectedCard];
self.detailController.title = selectedCard;
NSString* rating = component[@"$element"][@"Summary"][@"AverageRating"];
self.detailController.rating =(NSInteger)rating;
[self.navigationController pushViewController:self.detailController animated:YES];
}
}];
}
這是我BasicCardView
code -
@implementation BasicCardViewController
@synthesize userPageLink = _userPageLink;
@synthesize nodePage = _nodePage;
- (void)viewDidLoad {
_trendingImageView.image = [UIImage imageNamed:@"trending.png"];
}
- (UILabel *)label {
return (id)self.view;
}
- (void)loadView {
self.rateView = [[RateView alloc] init];
}
- (void)setDescription:(NSString *)description {
_description = description;
_descriptionView.text = description;
}
- (void)setPageScore:(NSString *)pageScore {
_pageScore = pageScore;
_pageScoreLabel.text = pageScore;
}
- (void)setRestaurantImage:(UIImage *)restaurantImage {
_restaurantImage.image = restaurantImage;
}
- (void)setPageTitle:(NSString *)title {
_pageTitle = title;
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear: animated];
self.rateView.notSelectedStar =[UIImage imageNamed:@"kermit_empty.png"];
self.rateView.halfSelectedStar = [UIImage imageNamed:@"kermi_half.png"];
self.rateView.fullSelectedStar = [UIImage imageNamed:@"kermit_full.png"];
self.rateView.rating = self.rating;
self.rateView.editable = YES;
self.rateView.maxRating = 5;
self.rateView.delegate = self;
_pageTitleLabel.text = _pageTitle;
}
單擊單元格時爲什麼不顯示?
但是,如果我在viewDidLoad
中做self.view = rateView
,rateView出現。
對..但我的觀點不只是比率視圖 - 還有其他一些東西。費率視圖是它的一個組件,我的xib文件也有一堆標籤和東西。我在其他地方調用了initWithNibName,所以self.detailController應該是一個視圖控制器,該視圖控制器使用具有費率視圖和標籤以及其他東西的xib文件初始化。 – praks5432
視圖控制器中是否顯示了其他視圖? – ldindu
好吧,如果我做self.view = oneOfMyLabels然後標籤顯示 – praks5432