试图连续3天解决这个问题,但仍然没有。 所以我想使用pop菜单中的滑块来控制uiview的alpha,该滑块从rect按钮出现(按下按钮) 所以我已经做了,
mainview .h文件:
@class popView;
@interface brightscreenViewController : UIViewController <UIPopoverControllerDelegate>
{
IBOutlet UIView *darkView;
IBOutlet UIButton *brightbtn;
UIPopoverController *popvover;
popView *pop;
}
@property(nonatomic, retain) UIPopoverController *popover;
@property (nonatomic, retain) UIView *darkView;
@property (nonatomic, retain) popView *pop;
- (IBAction)showPop:(id)sender;
mainview .m文件:
#import "brightscreenViewController.h"
#import "popView.h"
@class popView;
@interface brightscreenViewController ()
@end
@implementation brightscreenViewController
@synthesize popover;
@synthesize darkView;
@synthesize pop;
-(IBAction)showPop:(id)sender
{
popView *brightpop = [[popView alloc] init];
popover = [[UIPopoverController alloc] initWithContentViewController:brightpop];
[popover setDelegate:self];
[popover presentPopoverFromRect:[brightbtn bounds] inView:brightbtn permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[popover setPopoverContentSize:CGSizeMake(229, 57)];
}
和第二个视图.h,其中包含uipopview和滑块:
@class brightscreenViewController;
@interface popView : UIViewController
{
brightscreenViewController *brightscreen;
IBOutlet UISlider *slider;
}
@property (nonatomic, retain)UISlider *slider;
@property (nonatomic, retain) brightscreenViewController *brightscreen;
-(IBAction)setBrightness:(id)sender;
secondview .m文件:
#import "popView.h"
#import "brightscreenViewController.h"
@interface popView ()
@end
@implementation popView
@synthesize slider;
@synthesize brightscreen;
-(IBAction)setBrightness:(id)sender
{
brightscreen.darkView.alpha = slider.value;
}
pop over工作得很好但不是滑块。它只是没有回应。 我已经尝试使用相同的代码将滑块直接放在主视图上,它工作得很好,但当我把它与uipopover一起工作时不工作 我真的希望有人可以帮助我。
答案 0 :(得分:1)
怎么样:
popView *brightpop = [[popView alloc] init];
// New line
brightpop.brightscreen = self;
popover = [[UIPopoverController alloc] initWithContentViewController:brightpop];