0
votes

Im using a custom ModalViewController called MZFormSheetController to display a Detail View for UICollectionView. Currently I have created properties in the modal view controller such as these :

@property (strong,nonatomic) NSString *user;
@property (strong,nonatomic) NSString *caption;
@property (weak, nonatomic) IBOutlet UILabel *username;
@property (weak, nonatomic) IBOutlet UILabel *captiontext;

And I attempt to set the display of the detail view controller when the user taps on the UICollectionViewCell like this: - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {

NSDictionary *entry = [self entries][indexPath.row];
NSDictionary *text = [self entries][indexPath.row];

ModalViewController *m = [self.storyboard instantiateViewControllerWithIdentifier:@"modalView"];
m.entry = [self entries][indexPath.row];
m.text = [self entries][indexPath.row];
m.user = entry[@"user"][@"full_name"];
m.caption = text[@"caption"][@"text"];

MZFormSheetController *formSheet = [[MZFormSheetController alloc] initWithViewController:m];
formSheet.transitionStyle = MZFormSheetTransitionStyleDropDown;
formSheet.shouldDismissOnBackgroundViewTap = YES;
[formSheet presentAnimated:YES completionHandler:^(UIViewController *presentedFSViewController) {

}];
formSheet.didTapOnBackgroundViewCompletionHandler = ^(CGPoint location)
{

};

}

I have created two labels in storyboard for the modalviewcontroller and I attempt to make them equal the caption and user values from the MainViewController like this

[self.username.text isEqualToString:self.user];
[self.captiontext.text isEqualToString:self.caption];

However after all this the labels of the modal view controller still say label like this..

Failed Attempt at DetailViewController

2

2 Answers

0
votes

Your labels are not being updated to the correct values because the -isEqualToString: method is used to test whether two NSStrings are equal, and it doesn't actually set the value of any NSString. If you want to assign a value to a string variable, you do it the same as you would assign any other variable. Therefore, in order to set the labels properly, you just need to assign the text property of the UILabels, like this:

self.username.text = self.user;
self.captiontext.text = self.caption;
0
votes

Did you set username and captiontext inside your ModalViewController in viewDidLoad method ? After init from storyboard, all IBOutlets are nil, you need to setup then inside viewDidLoad.

- (void)viewDidLoad 
{
   [super viewDidLoad];

   self.username.text = self.user;
   self.captiontext.text = self.caption;
}