ios - 为什么在 IOS 中单击按钮时 View 不显示?

标签 ios objective-c uicollectionview

我是IOS新手,想通过collectionView实现相册在 IOS 中。

当我点击filebrowserbutton button时在 first View ,它将更改为second View (名称:AITCameraCollectionBrowser)。

有两个button和一个 collectionViewAITCameraCollectionBrowser就像下图一样。

enter image description here

它的头文件代码如下。

#import <UIKit/UIKit.h>

@interface AITCameraCollectionBrowser : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource>
@property (strong, nonatomic) IBOutlet UIButton *backButton;
@property (strong, nonatomic) IBOutlet UIButton *localAlbumButton;
@property (strong, nonatomic) IBOutlet UICollectionView *collectionview;

@end

我还没有从手机加载图片,所以它应该显示 view就像上图一样,当我点击 change view button 时在 first view .

代码filebrowserbutton button就像下面这样。

- (IBAction)filebrowserbutton:(id)sender {

    UIViewController *viewController = nil ;

    viewController = [[AITCameraCollectionBrowser alloc] initWithNibName:@"AITCameraCollectionBrowser" bundle:nil] ;

    viewController.edgesForExtendedLayout = UIRectEdgeNone;

    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil) style: UIBarButtonItemStyleBordered target:nil action:nil] ;
    [self.navigationController pushViewController:viewController animated:YES];
}

上面的代码buttonfirst view没问题。

但是当我点击 filebrowserbutton button 时它没有显示任何内容,它只有 backBarButtonItem在屏幕顶部。

所以问题出在第二个 View 上,我不知道为什么 buttoncollectionView没有显示?

最佳答案

在您的 header 或 .h 文件中,添加以下代码

- (IBAction)filebrowserbutton:(id)sender;

接下来,在您的 xibstoryboard 文件中,您必须从您的文件所有者处连接 filebrowserbutton(通过右键-单击第一张图片左侧的黄色透明框)按钮,然后选择内部修饰

关于ios - 为什么在 IOS 中单击按钮时 View 不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21593153/

相关文章:

iOS - Tesseract - 无法读取多维数据集语言模型 Cube ERROR (CubeRecoContext::Create):无法初始化 CubeRecoContext 对象

ios - 使用 CFStringGetHyphenationLocationBeforeIndex 添加连字符

objective-c - 如何将光标位置向前移动特定长度?

ios - 使用 IGListKit 在layoutSubviews() 中更改 UICollectionView 的框架和 contentInset

ios - UIButton 触摸事件 - Swift

ios - 是否 drawRect : automatically check whether something is within the bounds of the CGRect passed to it?

ios - 边界在带有内容插入的 UIScrollView 上自动更改

objective-c - iOS 应用的登录结构

ios - header 未显示在 UICollectionViewController Swift 中

ios - 在 UISearchController 下添加水平滚动过滤器选项