-(void)loadWebPage{
NSString *s=@"http://www.baidu.com";
NSURL *strURL=[NSURL URLWithString:s];
NSURLRequest *urlReq=[NSURLRequest requestWithURL:strURL];
[vWebPage loadRequest:urlReq];
多媒体类
animation
h文件
IBOutlet UIImageView *conImg;
m文件
//create the obj of the imgs
conImg.animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"img1.png"],
[UIImage imageNamed:@"img2.png"],
[UIImage imageNamed:@"img3.png"], nil];
conImg.animationDuration=1.0;
conImg.animationRepeatCount=2;
[conImg startAnimating];
[self.view addSubview:conImg];//注:貌似这句话可有可无
zoom the picture
h文件
//uiscrollviewdelegate委托协议
IBOutlet UIImageView *conImg;
IBOutlet UIScrollView *conScrollView;
m文件
//set scrollview controller as large as the img controller on the size
conScrollView.contentSize=conImg.image.size;
conImg.frame=CGRectMake(0., 0., conImg.image.size.width, conImg.image.size.height);
//trigger this method
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return conImg;
}
//set the zoom property of the scale
paging the book
h文件
//uiscrollviewdelegate 挂载,同时在IB中也要对接,不需要用到uiimageview控件
IBOutlet UIScrollView *conScrollView;
//m文件
//set the contentsize of scrollview
conScrollview.contentSize=CGSizeMake(320*4, 480);
int i;
for (i=1; i<5; i++) {
//create several imgs in the scrollview
UIImageView *img=[[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat: @"%d.png",i]]]autorelease];
//set every picture position on the scrollview
img.frame=CGRectMake((i-1)*320, 0., 320,480 );
//add the imgview into the scrollview
[conScrollview addSubview:img];
}
applying the gesture
//create and init the gesture
UISwipeGestureRecognizer *gSwipe=[[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeAction:)]autorelease];//此处非常重要的一点是需要参数就需要加冒号!!!
//specify the direction
gSwipe.direction=UISwipeGestureRecognizerDirectionLeft;
//add the gesture into view
[self.view addGestureRecognizer:gSwipe];
//在加载模态窗体的时候最重要的一点是,需要再建一个xib的viewcontroller,然后在present和dismiss的时候都要考虑需要不需要import各自的viewcontroller文件
//在写方法的时候,有一个注意点就是形参需要加括号,参数名前面的*和参数名一个在括号里一个在括号外面
//specify the method
-(void) SwipeAction: (UISwipeGestureRecognizer *)g{
//create a uiviewcontroller
pictureViewController *pictureView=[[[pictureViewController alloc]initWithNibName:@"pictureViewController" bundle:nil]autorelease];
//set the present style
pictureView.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
//open the animation enable
[self presentModalViewController:pictureView animated:YES];
}
//dismissmodalviewcontroller
-(void) gSwipeRight : (UISwipeGestureRecognizer *)g{
self.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self dismissModalViewControllerAnimated:YES];
}
文件操作类
//文件操作类,主要用到NSManager
NSFileHandle这两个类