popToViewController:的具体应用
rootviewcontroller在self.navigationController.viewControllers数组中的位置为0;其他依次。
[self.navigationController popToViewController:[self.navigationController.viewControllersobjectAtIndex:1] animated:YES];
//Viewcontroller转屏.m文件中加入
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
IOS播放器 加速减速播放
_moviePlayer =[[MPMoviePlayerController alloc] init];
_moviePlayer.fullscreen=YES;
_moviePlayer.currentPlaybackRate = 1.0;//1.0正常速度,负是回放,大于1.0就是加速。
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
_moviePlayer.view.userInteractionEnabled=NO;
_moviePlayer.view.frame = _mainImageView.frame;
IOSWebview 获取图片
-(void)addTapOnWebView
{
UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:selfaction:@selector(handleSingleTap:)];
[self.Detail_web addGestureRecognizer:singleTap];
[singleTap release];
singleTap.delegate = self;
singleTap.cancelsTouchesInView = NO;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
-(void)handleSingleTap:(UITapGestureRecognizer *)sender
{
CGPoint pt = [sender locationInView:self.Detail_web];
//根据坐标获取图片地址
NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", pt.x, pt.y];
NSString *urlToSave = [self.Detail_web stringByEvaluatingJavaScriptFromString:imgURL];
NSLog(@"image url=%@", urlToSave);
if (urlToSave.length > 0) {
[self showImageURL:urlToSave point:pt];
}
}
-(void)showImageURL:(NSString *)url point:(CGPoint)point
{
XMutableImageView *xm_imageview=[[XMutableImageView alloc]init];
xm_imageview.delegate=self;
[xm_imageview ImageVeiwLoadUrl:url];
[self.view addSubview:xm_imageview];
[xm_imageview release];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
//移除图片查看视图
-(void)handleSingleViewTap:(UITapGestureRecognizer *)sender
{
for (id obj in self.view.subviews) {
if ([obj isKindOfClass:[UIImageView class]]) {
[obj removeFromSuperview];
}
}
[self.navigationController setNavigationBarHidden:NO animated:YES];
}