[英]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 button
在first 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. 上面的
button
在first 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 ? 所以问题出在第二个视图上,我不知道为什么
button
和collectionView
没有显示?
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
. 接下来,在
xib
或storyboard
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.