我的 ViewController 现在有一个视图控制器和一个 UIView,当我单击 barButton 时,第二个视图会像弹出窗口一样出现,现在我想在第二个视图中添加页面控制器和滚动视图,我的第二个视图不是 UIViewController 但它是 UIView.so我怎样才能做到这一点...
我的第一个视图是“ImageViewController”,第二个视图是“PopupView”
在 ImageViewController.m
#import "PopupView.h"
@implementation ImageViewController
- (void)viewDidLoad
{
UIBarButtonItem *clipArt = [[UIBarButtonItem alloc] initWithTitle:@"Clip Art"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(popUpView:)];
}
- (void)popUpView:(id)sender {
CGRect * imageFrame = CGRectMake(10, 90, 300, 300);
PopupView *popUpView = [[PopupView alloc] initWithFrame:imageFrame];
[self.view addSubview:popUpView];
}
在 PopupView.m
- (id)initWithFrame:(CGRect)frame
{
if (self) {
CGRect * imageFrame = CGRectMake(0, 0, 300, 300);
self = [super initWithFrame:frame];
UIImageView *starImgView = [[UIImageView alloc] initWithFrame:imageFrame]; //create ImageView
starImgView.alpha =0.8;
starImgView.layer.cornerRadius = 15;
starImgView.layer.masksToBounds = YES;
starImgView.image = [UIImage imageNamed:@"black"];
[self addSubview:starImgView];
self.backgroundColor = [UIColor clearColor];
}
return self;
}