我正试图在ImagePicker
上提出collectionViewController
,但每次我的代码运行时,我都会收到错误消息:
警告:尝试在< CameraViewController上显示UIImagePickerController:0x15c50a370:0x15c6098a0>已经呈现(null)
这是我的代码:
#import "HomeViewController.h"
#import <Parse/Parse.h>
#import "PhotoCell.h"
@interface HomeViewController ()
@end
@
implementation HomeViewController
-
(void)viewDidLoad
{
[super viewDidLoad];
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
HomeViewController *vc = (HomeViewController *) [storyBoard instantiateViewControllerWithIdentifier:@"Home"];
[vc initWithCoder:nil];
self.edgesForExtendedLayout = UIRectEdgeNone;
self.title = @"fade";
self.collectionView.backgroundColor = [UIColor whiteColor];
[self.collectionView registerClass:[PhotoCell class] forCellWithReuseIdentifier:@"photo"];
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
NSLog(@"Current User: %@", currentUser.username);
}
else {
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showLogin"]) {
[segue.destinationViewController setHidesBottomBarWhenPushed:YES];
}
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 10;
}
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"photo";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
cell.backgroundColor = [UIColor lightGrayColor];
return cell;
}
- (id)initWithCoder:(NSCoder*)coder
{
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(306.0, 306.0);
layout.minimumInteritemSpacing = 150.0;
layout.minimumLineSpacing = 50.0;
return (self = [super initWithCollectionViewLayout:layout]);
}
@end