简体   繁体   English

当我单击IOS中的按钮时,为什么视图不显示?

[英]Why the view doesn't show when I click the button in IOS?

I am new to IOS , and I want to implement the album by collectionView in IOS. 我是IOS的新手,我想通过IOS中的collectionView实现相册。

When I click the filebrowserbutton button in first View , it will change to the second View (name: AITCameraCollectionBrowser ). 当我在first View单击filebrowserbutton button时,它将更改为second View (名称: AITCameraCollectionBrowser )。

There has two button and a collectionView in AITCameraCollectionBrowser like the following picture. 如下图所示, AITCameraCollectionBrowser有两个button和一个collectionView

在此处输入图片说明

And the code of it's header file is like the following code. 它的头文件的代码类似于以下代码。

#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

I have not load the picture from phone yet , so it should show the view like the above picture when I click the change view button in first view . 我还没有加载从手机的图片还没有,所以它应该显示view像上面的图片当我点击change view buttonfirst view

The code of filebrowserbutton button is like the following. 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];
}

The above code of button in first view is no problem. 上面的buttonfirst view代码没问题。

But it doesn't show anything when I click the filebrowserbutton button , it only has a backBarButtonItem on the top of screen. 但是当我单击filebrowserbutton button ,它什么都没有显示,它在屏幕顶部只有一个backBarButtonItem

So the problem is at second view , and I don't know why the button and collectionView is not show ? 所以问题出在第二个视图上,我不知道为什么buttoncollectionView没有显示?

In you're header, or .h file, add the following code 在您的标头或.h文件中,添加以下代码

- (IBAction)filebrowserbutton:(id)sender;

next, in you're xib or storyboard file, you have to connect filebrowserbutton from you're file's owner (by right-clicking the yellow, transparent box on the left of you're first picture) to the button, and choose touch up inside . 接下来,在xibstoryboard xib文件中,必须将文件所有者的filebrowserbutton (通过右键单击第一张图片左侧的黄色透明框)连接到该按钮,然后选择touch up inside

You need to add - (IBAction)filebrowserbutton:(id)sender; 您需要添加- (IBAction)filebrowserbutton:(id)sender; to your header file and connect it to your button's touchDown method. 到头文件,然后将其连接到按钮的touchDown方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我点击输入时,IOS 上的 Angular 应用程序不显示键盘。 为什么? - Angular app on IOS doesn't show me keyboard, when i click on input. Why? iOS-为什么不显示表格视图? - iOS - Why table view doesn't show? 当我在iOS中点击google上的标记时,如何使用两个按钮显示叠加信息视图 - How to show overlay info view with two button more when i click a marker on google in iOS iOS:UISplitViewController显示/隐藏主视图按钮不起​​作用 - iOS: UISplitViewController show/hide master view button doesn't work ios noob:为什么我的视图控制器不显示我在检查器中分配的标题 - ios noob: why doesn't my view controller show the title that I have assigned in the inspector 为什么第二次按下视图时后退按钮不显示? - Why doesn't the back button show up the second time I push the view? 当我单击直接查看时,ios locationInView无法显示正确的日志 - ios locationInView not show correct log when I click direct view 在AVCaptureVideoPreviewLayer顶部时,为什么我的按钮文本不显示? - Why doesn't my button text show when on top of AVCaptureVideoPreviewLayer? iOS:不显示收藏夹视图 - iOS : Collection view doesn't show 如何在按钮单击iOS上显示随机视图控制器 - How to show random view controller on button click iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM