在mainviewcontroller上有一个playpause按钮。这个按钮基本上是切换播放和暂停按钮,这是正常工作。现在我添加了另一个动作来玩playpause按钮。当我点击播放按钮时,它不会在播放和暂停之间切换的同时显示网页浏览。添加了多个操作@selector
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import "ModalViewController.h"
#import "PageOneViewController.h"
@interface MainViewController : UIViewController <ModalViewControllerDelegate>
- (void)modalViewAction:(id)sender;
@property (nonatomic, retain) UIToolbar *toolbar;
@property (nonatomic, assign) UIBarButtonSystemItem currentSystemItem;
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ModalViewController *viewController;
@property (strong, nonatomic) UINavigationController *navigationController;
@property (strong, nonatomic) UIPageViewController *pageViewController;
@end
@synthesize pageViewController = _pageViewController;
UIButton *playpauseButton = [UIButton buttonWithType:UIButtonTypeCustom];
[playpauseButton addTarget:self action:@selector(playpauseAction:) forControlEvents:UIControlEventTouchUpInside];
[playpauseButton addTarget:self action:@selector(pageViewControllerAction:) forControlEvents:UIControlEventTouchUpInside];
playpauseButton.frame = CGRectMake(0, 0, 50, 50);
[playpauseButton setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
[playpauseButton setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
UIBarButtonItem *playpause = [[UIBarButtonItem alloc] initWithCustomView:playpauseButton];
-(void)playpauseAction:(id)sender
{
if ([audioPlayer isPlaying]){
[sender setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
[audioPlayer pause];
} else {
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
[audioPlayer play];
}
}
- (void)pageViewControllerAction:(id)sender
{
CGRect pageViewRect = self.view.bounds;
pageViewRect = CGRectInset(pageViewRect, 40.0, 40.0);
self.pageViewController.view.frame = pageViewRect;
// Configure the page view controller
UIPageViewController *pageViewController = [[[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil]autorelease];
NSArray *viewControllers = [NSArray arrayWithObject:pageViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self.view addSubview:self.pageViewController.view];
}
试过异常断点它显示异常断点在
[audioPlayer play];
也尝试添加断点
-(void)pageViewControllerAction:
它不执行这一点。
任何想法正在发生。我做错了什么。
感谢您的帮助。
不,它是在那里,我忘了在这里输入它 – user1120133 2012-02-03 22:59:26
你有没有在你的头文件中定义它们? – 2012-02-03 23:00:07